bryanbcook / azdevops-testplan-extension

Azure DevOps extension that can publish cross-platform test results to a Test Plan
13 stars 4 forks source link

Publish Test Plan Results

This custom Azure Pipeline task makes it possible to update your Azure DevOps Test Plan using the results of your test automation suite, regardless of which test framework you're using (Cucumber, JUnit, xUnit, others).

- task: PublishTestPlanResults@1
  inputs:
    testPlan: 'Test Plan 01'
    testResultFormat: xUnit
    testResultFiles: $(Build.StagingDirectory)/testResults.xml

Track Progress

Results from your Test Automation are available in Test Plans / Runs:

Test Run

Progress is reflected in your Test Cases:

Test Cases

And overall progress is reflected in the Test Plan report:

Test Report

A quick primer on Azure Test Plans

It's helpful to understand the following about Azure Test Plans:

The combination of Test Case + Test Configuration is referred to as a Test Point.

When we publish our test results from our test framework to the Test Plan, we are interested in creating a Test Run that contains an outcome for each Test Point. There is a one-to-one mapping between each individual automated test and a Test Point.

Mapping Test Results to Test Cases

The PublishTestPlanResults task supports several different mapping strategies to help you link your test framework results to Test Cases (Test Points). The default auto strategy will attempt to find the appropriate strategy for you, or you can customize the configuration to meet your needs.

Test Case Mapping Strategies

The following strategies are used to match the test automation result to individual Test Point items:

Test Config Mapping Strategies

If your Test Plan supports multiple Test Configurations, you'll need a mechanism to map the test results to the appropriate Test Configuration.

If you've specified a testConfigFilter then only TestPoints for that Test Configuration will be updated. However, if your test-automation contains the outputs from multiple configurations, additional configuration settings are needed:

Examples

Basic Usage (xUnit)

In this example, we're using a trait named TestId to hold the id of the TestCase in our TestPlan.

[Fact]
[Trait("TestId","12345")] // 12345 is a TestCase identifier in our TestPlan
public void AddItemToShoppingCart() {
  // ... test automation
}

In our Azure Pipeline, after running your tests, you can update your Azure Test Plan Test Plan 01 using the following syntax:

- task: PublishTestPlanResults@1
  inputs:
    testPlan: 'Test Plan 01'
    testResultFormat: xUnit
    testResultFiles: $(Build.StagingDirectory)/testResults.xml
    testCaseMatchingStrategy: property
    testCaseProperty: TestId