Editéieren

Test reports

These features require installing additional NuGet packages, as described in each section.

Tip

When using Microsoft.Testing.Platform.MSBuild (included transitively by MSTest, NUnit, and xUnit runners), these extensions are auto-registered when you install their NuGet packages — no code changes needed. The manual registration specified in this article is only required if you disabled the auto-generated entry point by setting <GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>.

Report file names

Every report extension writes its file to the test results directory, which you can set with the --results-directory option. To override the name, use the matching --report-*-filename option. Each report section lists the default name for that report.

A file name can include a relative path that stays within the test results directory, and it can use the following replacement items (placeholders):

Placeholder Description
{asm} Entry assembly name, or unknown when it's unavailable.
{tfm} Target framework moniker detected at runtime, such as net9.0.
{arch} Process architecture, such as x64, x86, or arm64.
{pname} Process name.
{pid} Process ID.
{time} High-precision timestamp.

For example, --report-trx-filename "{asm}_{tfm}_{arch}.trx" reproduces the default TRX name.

Note

Placeholder names are case-sensitive and use lowercase. Placeholder support for report file names is available in MTP starting with version 2.3.0.

Report consolidation

Starting with MTP 2.4.0, MTP automatically post-processes report artifacts after a dotnet test invocation runs multiple test modules or after retry support runs multiple attempts. The feature is experimental in MTP 2.4.0.

The TRX, JUnit, CTRF, and HTML extensions group compatible artifacts by report kind and write a consolidated report under the test results directory's merged subdirectory. CTRF consolidation combines module results and collapses retry attempts into the final test result with retry history. HTML consolidation creates a merged summary and preserves the original per-process reports.

For custom report extensions, the experimental IArtifactPostProcessor API exposes separate TestModules and RetryAttempts processing modes. For more information, see The IArtifactPostProcessor extensions.

Visual Studio test reports (TRX)

The Visual Studio test result file (or TRX) is the default format for publishing test results. This extension requires the Microsoft.Testing.Extensions.TrxReport NuGet package.

Manual registration

var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddTrxReportProvider();

Note

When using manual registration, register the TRX report provider last. The current implementation depends on registration order, so registering it after all other extensions ensures it captures all test data.

Note

Available in MTP starting with version 1.9.0, the TRX report includes the test Description field.

Note

Available in MTP starting with version 2.3.0, TRX results stream to disk as the run progresses. If the test host crashes, the TRX file keeps the results collected before the crash.

Options

Option Description
--report-trx Generates the TRX report.
--report-trx-filename The name of the generated TRX report. Starting with MTP 2.3.0, the default is the deterministic {asm}_{tfm}_{arch}.trx form; before MTP 2.3.0, the default was <UserName>_<MachineName>_<yyyy-MM-dd_HH_mm_ss.fffffff>.trx. To customize the name, see Report file names.

The report is saved inside the default TestResults folder that can be specified through the --results-directory command line argument.

HTML reports

The HTML report creates an interactive, self-contained HTML file for a test session. This extension requires the Microsoft.Testing.Extensions.HtmlReport NuGet package.

Note

Available in MTP starting with version 2.3.0. This extension is experimental, and its options and output format might change in a future version.

Manual registration

var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddHtmlReportProvider();

Options

Option Description
--report-html Generates the HTML report.
--report-html-filename The name of the generated HTML report. The value must end with .html. The default is {asm}_{tfm}_{arch}.html. To customize the name, see Report file names. Requires --report-html.

JUnit reports

The JUnit report creates a JUnit-compatible XML file for a test session. This extension requires the Microsoft.Testing.Extensions.JUnitReport NuGet package.

Note

Available in MTP starting with version 2.3.0. This extension is experimental, and its options and output format might change in a future version.

Starting with MSTest.Sdk 4.3, enable this extension with <EnableMicrosoftTestingExtensionsJUnitReport>true</EnableMicrosoftTestingExtensionsJUnitReport>. The extension isn't part of the Default or AllMicrosoft MSTest.Sdk profiles.

Manual registration

var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddJUnitReportProvider();

Options

Option Description
--report-junit Generates the JUnit XML report.
--report-junit-filename The name of the generated JUnit XML report. The value must end with .xml. The default is {asm}_{tfm}_{arch}.xml. To customize the name, see Report file names. Requires --report-junit.

CTRF reports

The CTRF report creates a JSON file that uses the Common Test Report Format for a test session. This extension requires the Microsoft.Testing.Extensions.CtrfReport NuGet package.

Note

Available in MTP starting with version 2.3.0. This extension is experimental, and its options and output format might change in a future version.

Manual registration

var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddCtrfReportProvider();

Options

Option Description
--report-ctrf Generates the CTRF JSON report.
--report-ctrf-filename The name of the generated CTRF JSON report. The value must end with .json. The default is <UserName>_<MachineName>_<assembly>_<tfm>_<timestamp>.ctrf.json. To customize the name, see Report file names. Requires --report-ctrf.

Starting with MSTest 4.4, CTRF results for retried tests include the retries and retryAttempts fields. When a test passes after an earlier failed attempt, its result also includes flaky: true. The terminal summary identifies flaky and retried tests. TRX and JUnit reports keep one final result per test instead of recording every attempt.

Azure DevOps reports

Azure DevOps report plugin enhances test running for developers that host their code on GitHub, but build on Azure DevOps build agents. It adds additional information to failures to show failure directly in GitHub PR.

Error annotation in GitHub PR files view

This extension requires the Microsoft.Testing.Extensions.AzureDevOpsReport NuGet package.

Manual registration

var builder = await TestApplication.CreateBuilderAsync(args);
builder.TestHost.AddAzureDevOpsProvider();

Options

Option MTP version Description
--report-azdo 1.9.0 Enables the Azure DevOps report generator. Errors and warnings are written to the output in a format that Azure DevOps understands.
--report-azdo-severity 1.9.0 Severity to use for reported events. Valid values are error (default) and warning.
--report-azdo-groups 2.4.0 Enables or disables per-assembly log groups. When enabled, each test assembly's output appears in a collapsible section of the Azure Pipelines log. Valid values are on and off. MTP 2.4.0 preview builds default to on; the stable MTP 2.4.0 release defaults to off. Requires --report-azdo.
--report-azdo-annotations 2.4.0 Enables or disables annotations for failed and skipped tests. Valid values are on (default) and off. Requires --report-azdo.
--report-azdo-flaky-history 2.3.0 Queries Azure DevOps test result history for the past N days (1-90) and annotates reported failures with flakiness context. Requires --report-azdo.
--report-azdo-demote-known-flaky 2.3.0 Demotes failures that are flaky enough in the Azure DevOps history window (default threshold is 25%) from errors to warnings. Requires --report-azdo and --report-azdo-flaky-history.
--report-azdo-quarantine-file 2.3.0 Path to a text file that lists quarantined test fully qualified names or glob patterns. Matching failures are reported as warnings. Requires --report-azdo.
--report-azdo-summary 2.3.0 Writes a Markdown job summary at the end of the test run and uploads it through ##vso[task.uploadsummary]. An optional file path argument overrides the default location ({testResultsDir}/azdo-summary-{tfm}.md). Requires --report-azdo.
--report-azdo-stackframe-filter 2.3.0 Adds regex patterns, matched against the fully qualified type prefix of each stack frame, that are skipped when the extension locates the user's call site to annotate. The option is repeatable, up to 16 patterns, and each pattern is compiled with a 500-ms match timeout. These patterns are additive to the extension's built-in MSTest assertion-implementation prefixes. Requires --report-azdo.
--report-azdo-upload-artifacts 2.3.0 Uploads test result files and/or adds build tags to Azure DevOps. Valid values are off (default), tags-only, files, and all.
--report-azdo-upload-artifact-include 2.3.0 Includes files in the Azure DevOps artifact upload using glob patterns relative to the test results directory. Defaults to **/*. Requires --report-azdo-upload-artifacts to be a value other than off.
--report-azdo-upload-artifact-exclude 2.3.0 Excludes files from the Azure DevOps artifact upload using glob patterns relative to the test results directory. Requires --report-azdo-upload-artifacts to be a value other than off.
--report-azdo-upload-artifact-name 2.3.0 Overrides the Azure DevOps artifact container name. Defaults to TestResults_{assemblyName}_{tfm}. Requires --report-azdo-upload-artifacts to be a value other than off.
--publish-azdo-test-results 2.3.0 Publishes test results live to the Azure DevOps Tests tab.
--publish-azdo-run-name 2.3.0 Sets a custom Azure DevOps test run name for live test-result publishing. Requires --publish-azdo-test-results.

Warning

Don't enable groups when multiple test assemblies run in parallel. Azure DevOps ##[group] and ##[endgroup] formatting commands are sequential and anonymous. Concurrent assembly output can interleave, cause incorrect group nesting, and put lines under the wrong assembly. If you use an MTP 2.4.0 preview build, pass --report-azdo-groups off to disable groups. The stable MTP 2.4.0 release disables groups by default. Pass --report-azdo-groups on only for a single assembly or serialized assembly execution.

Note

The MTP version column lists the first MTP version that contains each option. The Azure DevOps extension itself became stable in MTP 1.9.0 with --report-azdo and --report-azdo-severity; the remaining options were added in MTP 2.3.0 or 2.4.0.

The extension automatically detects that it is running in continuous integration (CI) environment by checking the TF_BUILD environment variable.

Starting with MTP 2.4.0, Azure DevOps Markdown summaries aggregate results across every test module in a dotnet test invocation. When you also enable code coverage, the summary includes covered and total counts, percentages, threshold results, and an indicator when coverage data is partial.

GitHub Actions reports

The GitHub Actions report emits GitHub Actions-native workflow commands so test runs produce a first-class experience on the runner: per-assembly log groups, failed and skipped test annotations (surfaced in the workflow Annotations tab and, when the source location resolves, on the pull request's Files changed diff), a Markdown job summary appended to the file referenced by GITHUB_STEP_SUMMARY, and slow-test notices.

This extension requires the Microsoft.Testing.Extensions.GitHubActionsReport NuGet package.

The extension activates only when the run is on GitHub Actions (the GITHUB_ACTIONS environment variable is true) and the --report-gh switch is set; otherwise it does nothing. When active, each feature is enabled by default and can be turned off individually with its --report-gh-* option.

Important

The --report-gh option belongs to Microsoft.Testing.Extensions.GitHubActionsReport. The GitHubActionsTestLogger package provides a different option, --report-github. The options aren't aliases and work only when the test project registers the package that owns the option.

Note

The extension is available starting with MTP 2.3.0. Starting with MTP 2.4.0, its public entry points are no longer experimental.

Manual registration

var builder = await TestApplication.CreateBuilderAsync(args);
builder.AddGitHubActionsProvider();

Options

Option MTP version Description
--report-gh 2.3.0 Enables the GitHub Actions report generator so test runs emit workflow commands. Requires the run to be on GitHub Actions.
--report-gh-groups 2.3.0 Enables or disables per-assembly log groups. Valid values are on (default) and off. Requires --report-gh.
--report-gh-annotations 2.3.0 Enables or disables annotations for failed and skipped tests. Valid values are on (default) and off. Requires --report-gh.
--report-gh-step-summary 2.3.0 Controls whether the extension writes a Markdown job summary to the file referenced by GITHUB_STEP_SUMMARY. Valid values are on (default), off, and, starting with MTP 2.4.0, on-failure. Requires --report-gh.
--report-gh-step-summary-sections 2.4.0 Selects summary content. Valid values are test-results, slow-tests, coverage, and all (default). Requires --report-gh and a summary mode other than off.
--report-gh-slow-test-notices 2.3.0 Enables or disables slow-test notices. Valid values are on (default) and off. Requires --report-gh.
--report-gh-slow-test-threshold 2.3.0 The duration a test can run before a slow-test notice is emitted. Accepts a bare number of seconds or a value with a unit suffix such as 90s, 2m, or 1.5h. The default is 60s. Requires --report-gh.

Starting with MTP 2.4.0, GitHub Actions Markdown summaries aggregate results across every test module in a dotnet test invocation. When you also enable code coverage, select coverage or all to include covered and total counts, percentages, threshold results, and an indicator when coverage data is partial.