Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to link published test results with the test plan test cases in Azure DevOps?

I am trying to run automated tests using Cypress in Azure DevOps and publishing the tests results(Using PublishTestResult@2 Task) as an XML file using JUnit XML Reporter and merging them.

I am having trouble linking these published test results with the test cases in my ADO Test Plans, to my understanding JavaScript frameworks are currently not supported in Visual Studio to associate the tests with the test case ID, is there a workaround with this? Any help appreciated!

Tried using Visual Studio to associate the tests, publishing the results as an artifact to see if there was a way.

like image 360
Jes Avatar asked Oct 19 '25 19:10

Jes


1 Answers

This question has come up before.

The short answer is it should be possible through automation.

The long answer is the test results that are produced from your build pipeline and the test results that are associated with a Test Plan are slightly different and you need a mechanism to map between them.

When looking at Test Plans in Azure DevOps, it's important to recognize:

  • A Test Plan has a set of Test Suites
  • A Test Suite has a set of Test Cases
  • Test Cases are reusable, but when you carry a Suite to another Plan it creates a copy of the original Test Suite.
  • A Test Plan has a set of Test Configurations. These can represent the various targets that your test cases will be executed against, typically Operating Systems, Web Browsers or combinations of the two. Even if you're not explicitly using them, they are required, so you need at least one.
  • While it might seem like you're simply executing a Test Case, you are actually executing a combination of the Test Plan + Test Case + Test Configuration. These three things taken together are referred to as a "Test Point".
  • Reporting for Test Plans is done by outcomes for Test Points, not Test Cases.

You need a mapping between the Test Points and your automated tests.

How Automated Test Cases Work

  • There is meta-data in each Test Case that represents a pointer to the test-automation. These fields are read-only in the user-interface and can only be set through Visual Studio (or through the REST API).
  • The feature in Visual Studio that performs the "linking" is a mechanism that puts the predictable, fully qualified test name (Namespace + Class Name + Method + dll Assembly) into the meta-data of the Test Case. It's because these values are predictable is why this feature is only supported for .NET.
  • The feature in Azure DevOps (VSTest@2) that runs the automated tests and publishes them to the Test Plan requires the Assembly, the Test Plan identifier, and Test Configuration identifier as inputs. It takes the test results (Namespace+Class+Method,Assembly) and maps them to the Test Cases to obtain the Test Points.

How you can map your Test Results

The challenge with creating a universally supported approach outside of the .NET ecosystem is the reliable mapping of the test name in the JUnit/NUnit/xUnit test result to the Test Case. JavaScript, Java and Cucumber frameworks are horribly inconsistent and can vary per implementation, so it ultimately requires that you, the developer, are responsible for establishing that mapping. If you can produce that mapping, the rest is automation against the REST APIs:

  1. Locate the Test Plan id
  2. Locate the Configuration Id
  3. Locate the Test Suites in the Test Plan
  4. Locate the Test Points in the Suite + Configuration
    • Correlate the Test Point to the Test Case ID
  5. Create a Test Run for these Test Points
  6. Obtain the Test Result for the Test Run
  7. Patch the Test Result with the outcomes from your automated test result

There is an article that describes the above here.

One approach to provide the mapping of Test Case to test result, is to put the ID of the Test Case in the title of the test, eg <TestCase-ID>_<TestName>.

Update 2024/01/30:

I have an Azure DevOps Extension that can perform the above. If you'd like to be added to the private-preview, please submit a request here

like image 157
bryanbcook Avatar answered Oct 22 '25 12:10

bryanbcook



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!