Precept 0.14.0

Precept.Reporting.AzureDevOps

Azure DevOps reporting for Precept: a test run per suite execution, with results filed against the Test Case work items the scenarios name, in their titles or in a tag.

dotnet add package Precept.Reporting.AzureDevOps
public sealed class Startup : IPreceptStartup
{
    public void ConfigureServices(IServiceCollection services, PreceptSettings settings) =>
        services.AddPreceptAzureDevOpsReporting();
}
Scenario: [41207] A customer checks out with a stored card
{
  "Reporting": {
    "AzureDevOps": {
      "OrganizationUrl": "https://dev.azure.com/example-org",
      "Project": "Web"
    }
  }
}

That scenario's result is filed against Test Case work item 41207, so the work item shows its own latest automated outcome and a test plan reports coverage from the run. A @tc:41207 tag does the same for a suite that prefers tags. A scenario covering two test cases names both, as [41207][41208] or two tags, and is reported against each. Unmapped tests are still part of the run. Set "OnlyMappedTests": true if the run should contain nothing else.

The title is read with TestCaseTitlePattern, a regular expression with a group named id (^\s*(?:\[(?<id>\d+)\]\s*)+ by default), so 41207: A customer checks out or TC-41207 … is a pattern away. See linking scenarios to test cases.

Add "TestPlanId": 412 to file the run under a test plan, and "TestSuiteId" to file only that suite and the suites below it. Precept then resolves the test point each scenario's work item occupies in that plan, which Azure DevOps requires of a planned result. A test that fills no point in the plan is left out of the run and counted in its comment. The token needs no scope beyond Test Management, though Work Items (read) lets each planned result carry its test case's real revision. See running against a test plan.

Results go through the Test Results API rather than a .trx published by the PublishTestResults task. The difference is the link to the work item. Results are batched, so a thousand-scenario suite costs about ten requests. A failing test's screenshots are uploaded as attachments of its result, up to MaxAttachmentBytes (8 MB by default), so a large Playwright trace is skipped unless the cap is raised. See what gets attached.

From a pipeline, pass the build's own token. It is a pipeline variable, never a value written into the repository:

- script: dotnet test
  env:
    PRECEPT_REPORTING__AZUREDEVOPS__PERSONALACCESSTOKEN: $(System.AccessToken)
    PRECEPT_REPORTING__AZUREDEVOPS__BUILDID: $(Build.BuildId)

The job needs Allow scripts to access the OAuth token, and the build service identity needs test management rights on the project.

Test runs are created from a build agent only, so a test plan's latest outcome is the pipeline's, not whatever a developer last ran while writing the scenario. A local run files nothing and asks for nothing. The reporter is never started, so a missing token is not an error there. To file from your own machine, add { "Reporting": { "CiOnly": false } } to precept.local.json. See CI and local runs for how a run is recognised as CI.

The test run's page is posted to the run's PreceptRunLinks as soon as Azure DevOps creates it, so a run that also reports to Teams gets an Open Azure DevOps button on its card. See linking a run's reports to each other.


Part of Precept, a .NET 10 test framework built on Microsoft.Testing.Platform. Full documentation: reporting · running a suite on CI · configuration · artifacts

Precept 0.14.0 · MIT · © 2026

Esc