|
1 | 1 | ---
|
2 |
| -title: Testing with dotnet test |
3 |
| -description: Learn more about how dotnet test works and its support for VSTest and Microsoft.Testing.Platform (MTP) |
| 2 | +title: Testing with 'dotnet test' |
| 3 | +description: Learn more about how 'dotnet test' works and its support for VSTest and Microsoft.Testing.Platform (MTP) |
4 | 4 | author: Youssef1313
|
5 | 5 | ms.author: ygerges
|
6 | 6 | ms.date: 03/26/2025
|
7 | 7 | ---
|
8 | 8 |
|
9 |
| -# Testing with dotnet test |
| 9 | +# Testing with 'dotnet test' |
10 | 10 |
|
11 |
| -This article will provide you with insights into the `dotnet test` CLI command, its history, and its compatibility with both VSTest and Microsoft.Testing.Platform (MTP). |
| 11 | +This article provides insights into the `dotnet test` CLI command, including its history compatibility with both VSTest and Microsoft.Testing.Platform (MTP). |
12 | 12 |
|
13 | 13 | The `dotnet test` command operates in two primary modes:
|
14 | 14 |
|
15 |
| -- VSTest mode: This is the default mode for `dotnet test` and was the only mode available before the .NET 10 SDK. It is primarily designed for VSTest but can also run Microsoft.Testing.Platform test via [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild/) NuGet package. |
16 |
| -- Microsoft.Testing.Platform mode: Introduced with the .NET 10 SDK, this mode exclusively supports test applications built with Microsoft.Testing.Platform. |
| 15 | +- *VSTest* mode: This is the default mode for `dotnet test` and was the only mode available before the .NET 10 SDK. It is primarily designed for VSTest but can also run Microsoft.Testing.Platform test via [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild/) NuGet package. |
| 16 | +- *Microsoft.Testing.Platform* mode: Introduced with the .NET 10 SDK, this mode exclusively supports test applications built with Microsoft.Testing.Platform. |
17 | 17 |
|
18 | 18 | > [!TIP]
|
19 | 19 | > For CLI reference, see [dotnet test](../tools/dotnet-test.md).
|
20 | 20 |
|
21 | 21 | ## VSTest mode of `dotnet test`
|
22 | 22 |
|
23 |
| -For an extended period, VSTest has been the only test platform in .NET. Consequently, dotnet test was exclusively designed for VSTest, with all command-line options tailored to VSTest. |
| 23 | +For a long time, VSTest was the only test platform in .NET. Consequently, `dotnet test` was exclusively designed for VSTest, with all command-line options tailored to VSTest. |
24 | 24 |
|
25 |
| -The process involves invoking the `VSTest` MSBuild target, which triggers other internal targets to run and ultimately runs vstest.console. This translates all `dotnet test` command-line options to their equivalents in vstest.console. |
| 25 | +The process involves invoking the `VSTest` MSBuild target, which triggers other internal targets to run and ultimately runs vstest.console. All `dotnet test` command-line options are translated to their equivalents in vstest.console. |
26 | 26 |
|
27 |
| -### Running MTP projects with VSTest mode |
| 27 | +### Run MTP projects with VSTest mode |
28 | 28 |
|
29 | 29 | `dotnet test` is typically designed to run VSTest projects in VSTest mode, as that was its original purpose. However, to run MTP projects in `dotnet test` VSTest mode, you can use the [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild). From the user's perspective, this support is enabled by setting the `TestingPlatformDotnetTestSupport` MSBuild property to true (it is false by default for backward compatibility reasons). In simple terms, setting this property to true will cause Microsoft.Testing.Platform.MSBuild to change the `VSTest` target behavior, redirecting it to call `InvokeTestingPlatform`. This is an MSBuild target included in Microsoft.Testing.Platform.MSBuild, responsible for correctly running MTP test applications as executables. This means that VSTest-specific command-line options are silently ignored in this mode, such as `--logger`. This implies that there should be a way to pass MTP-specific command-line options, such as `--report-trx`, which is equivalent to using `--logger trx` in VSTest. Given the current limitations of the `dotnet test` CLI, the only way to include MTP-specific arguments is by appending them after an additional `--`. For instance, `dotnet test -- --report-trx`.
|
30 | 30 |
|
@@ -75,20 +75,21 @@ When running `dotnet test` in VSTest mode, it is recommended to avoid including
|
75 | 75 |
|
76 | 76 | This scenario is not officially supported, and you should be aware of the following:
|
77 | 77 |
|
78 |
| -1. VSTest-specific command-line options will only apply to VSTest projects and not to MTP test applications. |
79 |
| -2. MTP-specific command-line options provided after `--` will be treated as RunSettings arguments for VSTest projects. |
| 78 | +- VSTest-specific command-line options will only apply to VSTest projects and not to MTP test applications. |
| 79 | +- MTP-specific command-line options provided after `--` will be treated as RunSettings arguments for VSTest projects. |
80 | 80 |
|
81 | 81 | #### Key takeaways
|
82 | 82 |
|
83 |
| -1. To run MTP test applications in `dotnet test` VSTest mode, you should use `Microsoft.Testing.Platform.MSBuild`, pass MTP-specific command-line options after the extra --, and set `TestingPlatformDotnetTestSupport` to true. |
84 |
| -2. VSTest-oriented command-line options are silently ignored. |
85 |
| -3. Due to these issues, we have introduced a new `dotnet test` mode specifically designed for MTP. We encourage MTP users to transition from the VSTest `dotnet test` mode to the new mode with the .NET 10 SDK. |
| 83 | +- To run MTP test applications in `dotnet test` VSTest mode, you should use `Microsoft.Testing.Platform.MSBuild`, pass MTP-specific command-line options after the extra `--`, and set `TestingPlatformDotnetTestSupport` to `true`. |
| 84 | +- VSTest-oriented command-line options are silently ignored. |
| 85 | +
|
| 86 | +Due to these issues, .NET has introduced a new `dotnet test` mode specifically designed for MTP. We encourage MTP users to transition from the VSTest `dotnet test` mode to the new mode with the .NET 10 SDK. |
86 | 87 |
|
87 | 88 | ## Microsoft.Testing.Platform (MTP) mode of `dotnet test`
|
88 | 89 |
|
89 |
| -To address the issues encountered when running `dotnet test` with MTP in VSTest mode, we introduced a new mode in the .NET 10 SDK that is specifically designed for MTP. |
| 90 | +To address the issues encountered when running `dotnet test` with MTP in VSTest mode, .NET introduced a new mode in the .NET 10 SDK that's specifically designed for MTP. |
90 | 91 |
|
91 |
| -To enable this mode, you should add a `dotnet.config` file to the root of the repository or solution. |
| 92 | +To enable this mode, add a `dotnet.config` file to the root of the repository or solution. |
92 | 93 |
|
93 | 94 | ```ini
|
94 | 95 | [dotnet.test:runner]
|
|
0 commit comments