diff --git a/docs/core/testing/microsoft-testing-platform-ai.md b/docs/core/testing/microsoft-testing-platform-ai.md index 91feccf7581b5..753e9d64b8c19 100644 --- a/docs/core/testing/microsoft-testing-platform-ai.md +++ b/docs/core/testing/microsoft-testing-platform-ai.md @@ -3,7 +3,7 @@ title: Microsoft.Testing.Platform (MTP) AI integrations description: Learn how MTP extensions access AI chat clients and configure the Azure AI Foundry provider. author: Evangelink ms.author: amauryleve -ms.date: 08/26/2026 +ms.date: 08/28/2026 ai-usage: ai-assisted --- @@ -14,6 +14,22 @@ The experimental [Microsoft.Testing.Platform.AI](https://www.nuget.org/packages/ > [!IMPORTANT] > The AI APIs use the `TPEXP` diagnostic ID and can change in a future release. The packages supply infrastructure to extensions; they don't add AI behavior to a test suite by themselves. +## Use AI coding tools for test workflows + +The packages in this article let MTP extensions call AI models during a test run. To use an AI coding assistant to create, analyze, or migrate tests in your repository, use the curated [.NET Agent Skills](https://github.com/dotnet/skills) instead. + +Choose a workflow based on your goal: + +| Goal | Skill or agent | +|---|---| +| Create or extend tests | Use the [`code-testing-agent` skill](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test/skills/code-testing-agent) from the [`dotnet-test` plugin](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test). The skill researches the codebase, plans the work, implements tests, and verifies the changes. | +| Run or troubleshoot tests | Use the [`run-tests` skill](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test/skills/run-tests) to execute tests or diagnose test execution without changing test code. | +| Audit test quality | Use the [`test-quality-auditor` agent](https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/agents/test-quality-auditor.agent.md) for a broad assessment, or invoke a focused skill from the [`dotnet-test` skills directory](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test/skills) for assertions, coverage, test gaps, or test smells. | +| Improve testability | Use the [`testability-migration` agent](https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/agents/testability-migration.agent.md) to find static dependencies and introduce testable abstractions. | +| Migrate a test framework or platform | Use the [`test-migration` agent](https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/agents/test-migration.agent.md) from the [`dotnet-test-migration` plugin](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test-migration). The agent detects the current setup and selects the appropriate migration skill. | + +For installation steps and supported coding agents, see the [.NET Agent Skills repository](https://github.com/dotnet/skills#installation). Install `dotnet-test` alongside `dotnet-test-migration` because migration workflows reuse its platform detection and test verification skills. + ## Choose the packages Add the abstractions package when you author an extension that consumes a chat client. Add a provider package to the test application that hosts the extension: diff --git a/docs/core/testing/microsoft-testing-platform-cli-options.md b/docs/core/testing/microsoft-testing-platform-cli-options.md index f10dbcdf8a015..c02814282d2cb 100644 --- a/docs/core/testing/microsoft-testing-platform-cli-options.md +++ b/docs/core/testing/microsoft-testing-platform-cli-options.md @@ -3,7 +3,7 @@ title: Microsoft.Testing.Platform (MTP) CLI options reference description: Find platform and extension command-line options for MTP in one place. author: Evangelink ms.author: amauryleve -ms.date: 08/26/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- @@ -11,6 +11,9 @@ ai-usage: ai-assisted This article gives a central entry point for MTP command-line options. +> [!IMPORTANT] +> Platform options are available from MTP itself. Extension options are available only when each targeted test application registers the extension package that provides them. Add the package directly, or use a test SDK configuration or profile that includes it. If a test application doesn't register the extension, the run fails with exit code 5 because the option is unrecognized. + ## Platform options - **`@`** @@ -183,22 +186,19 @@ This article gives a central entry point for MTP command-line options. ## Extension options by scenario -Use the following table to find extension options quickly. +Use the following table to find each extension's package and options. A test SDK profile can supply a package instead of a direct package reference. -| Scenario | Feature documentation | -|---|---| -| Collect code coverage | [Code coverage](./microsoft-testing-platform-code-coverage.md) | -| Collect crash or hang dumps | [Crash and hang dumps](./microsoft-testing-platform-crash-hang-dumps.md) | -| Generate test reports (for example TRX) | [Test reports](./microsoft-testing-platform-test-reports.md) | -| Customize terminal output | [Terminal output](./microsoft-testing-platform-terminal-output.md) | -| Apply hosting-level controls | [Hot Reload](./microsoft-testing-platform-hot-reload.md) | -| Retry failed tests | [Retry](./microsoft-testing-platform-retry.md#retry) | -| Run tests that use Microsoft Fakes | [Microsoft Fakes](./microsoft-testing-platform-fakes.md) | -| Emit OpenTelemetry traces and metrics | [OpenTelemetry](./microsoft-testing-platform-open-telemetry.md) | +| Scenario | Required component | Feature documentation | +|---|---|---| +| Collect code coverage | `Microsoft.Testing.Extensions.CodeCoverage` or `coverlet.MTP` | [Code coverage](./microsoft-testing-platform-code-coverage.md) | +| Collect crash or hang dumps | `Microsoft.Testing.Extensions.CrashDump` or `Microsoft.Testing.Extensions.HangDump` | [Crash and hang dumps](./microsoft-testing-platform-crash-hang-dumps.md) | +| Generate test reports | The extension package for the selected format, such as `Microsoft.Testing.Extensions.TrxReport` | [Test reports](./microsoft-testing-platform-test-reports.md) | +| Customize terminal output | MTP core (no additional package) | [Terminal output](./microsoft-testing-platform-terminal-output.md) | +| Retry failed tests | `Microsoft.Testing.Extensions.Retry` | [Retry](./microsoft-testing-platform-retry.md#retry) | ## Discover options in your test app -Run your test executable with `--help` to list the options available for your current extension set. +Run your test executable with `--help`, or run `dotnet test --help` in MTP mode, to list the options available for your current extension set. For advanced diagnostics of registered providers and options, run with `--info`. diff --git a/docs/core/testing/microsoft-testing-platform-config.md b/docs/core/testing/microsoft-testing-platform-config.md index e0248bef36aa9..e9ea1ea8dcb64 100644 --- a/docs/core/testing/microsoft-testing-platform-config.md +++ b/docs/core/testing/microsoft-testing-platform-config.md @@ -3,7 +3,7 @@ title: Microsoft.Testing.Platform (MTP) config options description: Learn how to configure MTP using testconfig.json configuration settings and environment variables. author: Evangelink ms.author: amauryleve -ms.date: 08/26/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- @@ -100,6 +100,8 @@ Before MTP 2.3.0, extension features such as [crash dump](microsoft-testing-plat Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json* through `IConfiguration`. This support includes extension options, so you can use JSON entries for options that you don't want to pass on the command line each run. Command-line arguments still take precedence. +Configuration doesn't install or register an extension. Each test application must reference the package that provides an extension option, either directly or through a test SDK configuration or profile. Otherwise, the option remains unrecognized whether you put it in *testconfig.json* or on the command line. + For a complete reference of command-line options, see [MTP CLI options reference](microsoft-testing-platform-cli-options.md). ### Test framework-specific settings @@ -146,9 +148,9 @@ If you're migrating from a *.runsettings* file, the following table maps common | `RunConfiguration/MaxCpuCount` | No equivalent | Process-level parallelism is controlled by `dotnet test --max-parallel-test-modules` or MSBuild `/m` option. | | `MSTest/*` | `mstest.*` | See [Configure MSTest — testconfig.json](unit-testing-mstest-configure.md#testconfigjson). | | `xUnit/*` | `xUnit.*` | See [xUnit.net testconfig.json](https://xunit.net/docs/config-testconfig-json). | -| `LoggerRunSettings/Loggers` | CLI options | Use `--report-trx` or similar CLI options. Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json*. | -| `DataCollectionRunSettings` (blame) | CLI options | Use `--crashdump` and `--hangdump` CLI options. Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json*. See [Crash and hang dumps](microsoft-testing-platform-crash-hang-dumps.md). | -| `DataCollectionRunSettings` (coverage) | CLI options | Use `--coverage` CLI option. Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json*. See [Code coverage](microsoft-testing-platform-code-coverage.md). | +| `LoggerRunSettings/Loggers` | CLI options | Use the option from the installed report extension. For example, `--report-trx` requires `Microsoft.Testing.Extensions.TrxReport`. Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json*. See [Test reports](microsoft-testing-platform-test-reports.md). | +| `DataCollectionRunSettings` (blame) | CLI options | Use `--crashdump` from `Microsoft.Testing.Extensions.CrashDump` or `--hangdump` from `Microsoft.Testing.Extensions.HangDump`. Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json*. See [Crash and hang dumps](microsoft-testing-platform-crash-hang-dumps.md). | +| `DataCollectionRunSettings` (coverage) | CLI options | Use `--coverage` from `Microsoft.Testing.Extensions.CodeCoverage`. Starting with MTP 2.3.0, MTP can read CLI options from *testconfig.json*. See [Code coverage](microsoft-testing-platform-code-coverage.md). | | `TestRunParameters` | `--test-parameter` CLI | Use `--test-parameter key=value` on the command line. | ## Environment variables diff --git a/docs/core/testing/microsoft-testing-platform-hot-reload.md b/docs/core/testing/microsoft-testing-platform-hot-reload.md index 51987d5053468..f961040f1ebc0 100644 --- a/docs/core/testing/microsoft-testing-platform-hot-reload.md +++ b/docs/core/testing/microsoft-testing-platform-hot-reload.md @@ -3,7 +3,7 @@ title: Microsoft.Testing.Platform (MTP) Hot Reload description: Learn about the MTP Hot Reload extension for running tests with hot reload. author: evangelink ms.author: amauryleve -ms.date: 02/25/2026 +ms.date: 08/28/2026 ai-usage: ai-assisted --- @@ -25,6 +25,8 @@ builder.TestHost.AddHotReloadProvider(); Hot reload lets you modify your app's managed source code while the application is running, without the need to manually pause or hit a breakpoint. Simply make a supported change while the app is running and select the **Apply code changes** button in Visual Studio to apply your edits. +If you use an AI coding assistant, the [`mtp-hot-reload` .NET Agent Skill](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test/skills/mtp-hot-reload) guides the assistant through setup and recovery from unsupported edits. This skill isn't an MTP extension or CLI plugin. + > [!NOTE] > The current version is limited to supporting hot reload in "console mode" only. There is currently no support for hot reload in Test Explorer for Visual Studio or Visual Studio Code. diff --git a/docs/core/testing/microsoft-testing-platform-test-reports.md b/docs/core/testing/microsoft-testing-platform-test-reports.md index 3c5aa9b8f4a5d..87d1c1c1de277 100644 --- a/docs/core/testing/microsoft-testing-platform-test-reports.md +++ b/docs/core/testing/microsoft-testing-platform-test-reports.md @@ -3,13 +3,13 @@ title: Microsoft.Testing.Platform (MTP) test reports description: Learn about the MTP extensions that create test report files (TRX, HTML, JUnit, CTRF, Azure DevOps, GitHub Actions). author: evangelink ms.author: amauryleve -ms.date: 08/26/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- # Test reports -These features require installing additional NuGet packages, as described in each section. +Each report option requires the extension package named in its section. Add the package directly, or use a test SDK configuration or profile that includes it. Report extensions aren't part of MTP core, so an option such as `--report-trx` is unrecognized when the test application doesn't register its extension. Run the test application with `--help`, or run `dotnet test --help` in MTP mode, to confirm that an option is available. > [!TIP] > When using [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/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 `false`. diff --git a/docs/core/testing/microsoft-testing-platform-troubleshooting.md b/docs/core/testing/microsoft-testing-platform-troubleshooting.md index 6a66c259c9c00..c59629643ab77 100644 --- a/docs/core/testing/microsoft-testing-platform-troubleshooting.md +++ b/docs/core/testing/microsoft-testing-platform-troubleshooting.md @@ -3,7 +3,7 @@ title: Microsoft.Testing.Platform (MTP) troubleshooting description: Troubleshoot MTP issues, exit codes, and known problems. author: Evangelink ms.author: amauryleve -ms.date: 06/01/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- @@ -111,8 +111,12 @@ This error can occur if not all of the Fakes assemblies are present in the bin f - Ensure that the project either uses the [MSTest.SDK](./unit-testing-mstest-sdk.md) or references [Microsoft.Testing.Extensions.Fakes](./microsoft-testing-platform-fakes.md). - For .NET Framework projects, avoid setting `AnyCPU` as this results in NuGet not copying all files to the bin folder. -### Unrecognized command-line option in solutions with mixed test frameworks or extensions +### Unrecognized extension command-line option -If your solution contains projects that use different test frameworks (for example, MSTest and xUnit.net) or different sets of extensions (for example, only some projects reference `Microsoft.Testing.Extensions.HangDump`), running `dotnet test` with a framework-specific or extension-specific command-line option can fail with exit code 5. The option is valid for one project but unrecognized by another. +An extension-specific command-line option can fail with exit code 5 when a test application doesn't register the package that provides the option. For example, `--report-trx` requires `Microsoft.Testing.Extensions.TrxReport`, either as a direct package reference or through a test SDK configuration or profile that includes the package. MTP core doesn't include report, code coverage, dump, retry, or other extension options. + +Run the test application with `--help`, or run `dotnet test --help` in MTP mode, to confirm that the option is available. If the option is missing, add its extension package or enable the extension through your test SDK. See [Extension options by scenario](microsoft-testing-platform-cli-options.md#extension-options-by-scenario) to find the required package. + +The same failure occurs when a solution contains projects that use different test frameworks (for example, MSTest and xUnit.net) or different sets of extensions (for example, only some projects reference `Microsoft.Testing.Extensions.HangDump`). The option is valid for one project but unrecognized by another. To resolve this issue, use the `TestingPlatformCommandLineArguments` MSBuild property with conditions to route arguments to the correct projects. For detailed instructions, see [Solutions with mixed test frameworks or extensions](unit-testing-with-dotnet-test.md#solutions-with-mixed-test-frameworks-or-extensions). diff --git a/docs/core/testing/migrating-vstest-microsoft-testing-platform.md b/docs/core/testing/migrating-vstest-microsoft-testing-platform.md index 11ec53c1026c5..74765d0a8bcb5 100644 --- a/docs/core/testing/migrating-vstest-microsoft-testing-platform.md +++ b/docs/core/testing/migrating-vstest-microsoft-testing-platform.md @@ -3,7 +3,7 @@ title: Migration guide from VSTest to Microsoft.Testing.Platform (MTP) description: Step-by-step guide to migrate from VSTest to Microsoft.Testing.Platform (MTP), including argument mapping, project configuration, and CI pipeline updates. author: Youssef1313 ms.author: ygerges -ms.date: 08/26/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- @@ -19,6 +19,9 @@ If you need detailed behavior of `dotnet test` modes, see [Testing with `dotnet If you need a single list of platform and extension command-line options, see [MTP CLI options reference](./microsoft-testing-platform-cli-options.md). +> [!TIP] +> To automate a repository-wide migration with an AI coding assistant, install the [`dotnet-test`](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test) and [`dotnet-test-migration`](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test-migration) plugins from [.NET Agent Skills](https://github.com/dotnet/skills). Ask the [`test-migration` agent](https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/agents/test-migration.agent.md) to detect and migrate your test setup, or invoke the [`migrate-vstest-to-mtp` skill](https://github.com/dotnet/skills/tree/main/plugins/dotnet-test-migration/skills/migrate-vstest-to-mtp) for this specific migration. Review the generated changes before you merge them. + ## Opt-in to use MTP The first step in the migration is to opt-in to using MTP. @@ -68,7 +71,7 @@ Starting with .NET 10 SDK, there is *native* support for MTP. To use it, you mus ``` > [!IMPORTANT] -> In this mode, the extra `--` is no longer used. +> In this mode, the extra `--` is no longer required. Keep it to forward test application arguments unambiguously. ### Update `dotnet test` invocations @@ -175,6 +178,9 @@ With MTP, this becomes: dotnet test --coverage --coverage-output-format cobertura ``` +> [!IMPORTANT] +> To use `--coverage`, each targeted test application must reference the `Microsoft.Testing.Extensions.CodeCoverage` NuGet package directly or through a test SDK configuration or profile that includes it. +> > [!IMPORTANT] > As explained earlier, when using MTP with the VSTest-based `dotnet test`, extra `--` is needed before the arguments intended to be passed to the platform. > So, this becomes `dotnet test -- --coverage --coverage-output-format cobertura`. @@ -223,7 +229,7 @@ dotnet test --report-trx ``` > [!IMPORTANT] -> To use `--report-trx`, you must have the `Microsoft.Testing.Extensions.TrxReport` NuGet package installed. +> To use `--report-trx`, each targeted test application must reference the `Microsoft.Testing.Extensions.TrxReport` NuGet package directly or through a test SDK configuration or profile that includes it. > > [!IMPORTANT] > As explained earlier, when using MTP with the VSTest-based `dotnet test`, extra `--` is needed before the arguments intended to be passed to the platform. @@ -291,6 +297,8 @@ If you're using the [VSTest task](/azure/devops/pipelines/tasks/reference/vstest arguments: '-- --report-trx --results-directory $(Agent.TempDirectory)' ``` + The test applications in this example must register `Microsoft.Testing.Extensions.TrxReport`. Add the package directly, or use a test SDK configuration or profile that includes it. + ## Behavioral differences between VSTest and MTP ### Running zero tests diff --git a/docs/core/testing/unit-testing-mstest-sdk.md b/docs/core/testing/unit-testing-mstest-sdk.md index a50b972faf72e..47b5f2dfadf7d 100644 --- a/docs/core/testing/unit-testing-mstest-sdk.md +++ b/docs/core/testing/unit-testing-mstest-sdk.md @@ -3,7 +3,7 @@ title: MSTest SDK configuration author: MarcoRossignoli description: Learn how to configure MSTest.Sdk profiles, extensions, and advanced features. ms.author: mrossignoli -ms.date: 08/27/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- @@ -239,6 +239,8 @@ Once you've updated your projects, if you're using MTP (default) and if you rely If you're using the VSTest mode of `dotnet test`, here's an example update when using the `DotNetCoreCLI` task in Azure DevOps: +The default MSTest.Sdk extension profile supplies the `Microsoft.Testing.Extensions.TrxReport` and `Microsoft.Testing.Extensions.CodeCoverage` packages required by the added options. If you select the `None` profile, enable or reference both extensions before you use the options. + ```diff \- task: DotNetCoreCLI@2 inputs: diff --git a/docs/core/testing/unit-testing-with-dotnet-test.md b/docs/core/testing/unit-testing-with-dotnet-test.md index 369e6bc4980e0..3c1a2158120c9 100644 --- a/docs/core/testing/unit-testing-with-dotnet-test.md +++ b/docs/core/testing/unit-testing-with-dotnet-test.md @@ -3,7 +3,7 @@ title: Testing with 'dotnet test' description: Learn more about how 'dotnet test' works and its support for VSTest and Microsoft.Testing.Platform (MTP) author: Youssef1313 ms.author: ygerges -ms.date: 06/05/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- @@ -29,6 +29,9 @@ The process involves invoking the `VSTest` MSBuild target, which triggers other `dotnet test` was designed to run VSTest projects in VSTest mode. However, you can run MTP projects in `dotnet test` VSTest mode by using the [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild) package. From the user's perspective, this support is enabled by setting the `TestingPlatformDotnetTestSupport` MSBuild property to `true` (it's `false` by default for backward-compatibility reasons). When this property is set to `true`, Microsoft.Testing.Platform.MSBuild changes the `VSTest` target behavior, redirecting it to call `InvokeTestingPlatform`. `InvokeTestingPlatform` is an MSBuild target included in Microsoft.Testing.Platform.MSBuild that's responsible for correctly running MTP test applications as executables. VSTest-specific command-line options, such as `--logger`, are silently ignored in this mode. To include MTP-specific arguments, such as `--report-trx`, you must append them after an additional `--`. For example, `dotnet test -- --report-trx`. In MTP 1.9, a warning with code MTP0001 is produced when an argument that is silently ignored is detected. +> [!IMPORTANT] +> The `--report-trx` option isn't built into MTP. Each targeted test application must register the extension by referencing [`Microsoft.Testing.Extensions.TrxReport`](https://www.nuget.org/packages/Microsoft.Testing.Extensions.TrxReport) directly or through a test SDK configuration or profile that includes the package. Otherwise, the test application rejects the option with MTP exit code 5. In this legacy VSTest mode, `dotnet test` can report that rejection as an MSBuild failure with exit code 1. + > [!NOTE] > MSTest and NUnit use the [Microsoft.Testing.Extensions.VSTestBridge](https://www.nuget.org/packages/Microsoft.Testing.Extensions.VSTestBridge) package. By setting `EnableMSTestRunner` or `EnableNUnitRunner` (which enables MTP), your test project will support both VSTest and MTP. > In that scenario, if you use the VSTest mode of `dotnet test` and do not set `TestingPlatformDotnetTestSupport` to true, you are essentially running entirely with VSTest, as if `EnableMSTestRunner` and `EnableNUnitRunner` are not set to true. @@ -154,7 +157,7 @@ For users of MTP that are using the VSTest mode of `dotnet test`, there are few 1. Add `test` section to your `global.json` file, as shown above. 1. Remove `TestingPlatformDotnetTestSupport` MSBuild property, as it's no longer required. 1. Remove `TestingPlatformCaptureOutput` and `TestingPlatformShowTestsFailure` MSBuild properties, as they are no longer used by the new `dotnet test`. -1. Remove the extra `--`, for example `dotnet test -- --report-trx` should become `dotnet test --report-trx`. +1. Treat the extra `--` as optional. For example, `dotnet test -- --report-trx` can become `dotnet test --report-trx`. Keep the separator to forward test application arguments unambiguously. Neither syntax installs the required `Microsoft.Testing.Extensions.TrxReport` extension. 1. If passing a specific solution (or directory containing solution), for example, `dotnet test MySolution.sln`, this should become `dotnet test --solution MySolution.sln`. 1. If passing a specific project (or directory containing project), for example, `dotnet test MyProject.csproj`, this should become `dotnet test --project MyProject.csproj`. 1. If passing a specific dll, for example, `dotnet test path/to/UnitTests.dll`, this should become `dotnet test --test-modules path/to/UnitTests.dll`. Note that `--test-modules` also supports globbing. @@ -200,6 +203,6 @@ dotnet test -p:MSTestSpecificArgs="--filter FullyQualifiedName~IntegrationTests" Each test project receives only the arguments relevant to its framework, and the other framework's arguments are never passed. > [!TIP] -> For arguments that are the same across all frameworks (such as `--ignore-exit-code 8` or `--report-trx`), set them directly in `TestingPlatformCommandLineArguments` without any condition. +> For arguments that every targeted project recognizes, set them directly in `TestingPlatformCommandLineArguments` without a condition. For example, all projects recognize `--ignore-exit-code 8`. You can pass `--report-trx` globally only when every targeted project registers `Microsoft.Testing.Extensions.TrxReport`. The same pattern applies when only some test projects in a solution reference a particular extension. For example, if only certain projects reference `Microsoft.Testing.Extensions.HangDump`, passing `--hangdump` globally causes the other projects to fail with an unrecognized option error. Use the same conditional approach to route extension-specific arguments only to the projects that have the extension. diff --git a/docs/core/tools/dotnet-test-mtp.md b/docs/core/tools/dotnet-test-mtp.md index 73305235510e6..ba59122148525 100644 --- a/docs/core/tools/dotnet-test-mtp.md +++ b/docs/core/tools/dotnet-test-mtp.md @@ -1,7 +1,7 @@ --- title: dotnet test command with Microsoft.Testing.Platform (MTP) description: The dotnet test command is used to execute unit tests in a given project using MTP. -ms.date: 06/05/2026 +ms.date: 08/31/2026 ai-usage: ai-assisted --- # dotnet test with Microsoft.Testing.Platform (MTP) @@ -47,6 +47,9 @@ dotnet test -h|--help With MTP, `dotnet test` operates faster than with VSTest. The test-related arguments are no longer fixed, as they are tied to the registered extensions in the test project(s). Moreover, MTP supports a globbing filter when running tests. For more information, see [MTP](../testing/microsoft-testing-platform-intro.md). +> [!IMPORTANT] +> Extension-specific options aren't built into MTP. Each targeted test application must register the extension that provides an option. Add the extension's NuGet package directly, or use a test SDK configuration or profile that includes the package. Otherwise, the test run fails with exit code 5 because the option is unrecognized. Run `dotnet test --help` to see the options available to the selected test applications, and see [Extension options by scenario](../testing/microsoft-testing-platform-cli-options.md#extension-options-by-scenario) to find the package for an option. + > [!WARNING] > When MTP is opted in via `global.json`, `dotnet test` expects all test projects to use MTP. It is an error if any of the test projects use VSTest. @@ -176,6 +179,8 @@ With MTP, `dotnet test` operates faster than with VSTest. The test-related argum dotnet test --results-directory TestResults -- --report-trx --report-trx-filename A.trx ``` +The preceding example requires the [`Microsoft.Testing.Extensions.TrxReport`](https://www.nuget.org/packages/Microsoft.Testing.Extensions.TrxReport) package, either as a direct package reference or through a test SDK configuration that includes it. + The same parser behavior applies to `dotnet run` and `dotnet build`. For a detailed example, see [Forward arguments to the application](dotnet-run.md#forward-arguments-to-the-application) in the `dotnet run` reference. ## Examples @@ -210,7 +215,7 @@ The same parser behavior applies to `dotnet run` and `dotnet build`. For a detai dotnet test --test-modules "**/bin/**/Debug/net10.0/TestProject.dll" --root-directory "c:\code" ``` -- Run the tests in the current directory with code coverage: +- Run the tests in the current directory with the Microsoft Code Coverage extension. The test application must reference [`Microsoft.Testing.Extensions.CodeCoverage`](https://www.nuget.org/packages/Microsoft.Testing.Extensions.CodeCoverage), either directly or through a test SDK configuration that includes it: ```dotnetcli dotnet test --coverage