Skip to content

Commit cffa1a4

Browse files
committed
Testing docs improvements
1 parent fc48880 commit cffa1a4

File tree

4 files changed

+211
-76
lines changed

4 files changed

+211
-76
lines changed

docs/core/testing/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ When running tests in .NET, there are two components involved: the test platform
3939

4040
### Test platforms
4141

42-
The test platform is the engine that runs the tests and acts as a communication channel with IDEs. For example, Visual Studio can send a discovery request to the test platform so that it can display the available tests in Test Explorer. The test platform responds back to the IDE with the tests it found. Similar communication happens for test execution.
42+
The test platform is the engine that runs the tests and acts as a communication channel with IDEs and CLI. For example, Visual Studio can send a discovery request to the test platform so that it can display the available tests in Test Explorer. The test platform responds back to the IDE with the tests it found. Similar communication happens for test execution.
4343

44-
VSTest has been used for many years in .NET and was the only test platform in the ecosystem. Early in 2024, the first stable version of a new test platform, called [Microsoft.Testing.Platform (MTP)](./microsoft-testing-platform-intro.md), was released.
44+
VSTest has been used for many years in .NET and was the only test platform in the ecosystem. Early in 2024, the first stable version of a new test platform, called [Microsoft.Testing.Platform (MTP)](./microsoft-testing-platform-intro.md), was released. For more information about migrating from VSTest to Microsoft.Testing.Platform, see [Migration guide from VSTest to Microsoft.Testing.Platform](./migrating-vstest-microsoft-testing-platform.md).
45+
46+
The test platform also provides extensibility APIs so that additional features can be implemented and get them working for all test frameworks. There are usually built-in features built on top of the extensibility APIs, such as TRX reporting and hang and crash dumps. The community can also build their own extensions that end up working for all test frameworks.
4547

4648
### Test frameworks
4749

docs/core/testing/microsoft-testing-platform-vs-vstest.md

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -55,78 +55,6 @@ You can also go to Preview Features options in Visual Studio and deselect the "U
5555

5656
VSTest ships multiple executables, notably `vstest.console.exe`, `testhost.exe`, and `datacollector.exe`. However, MSTest is embedded directly into your test project and doesn't ship any other executables. The executable your test project compiles to is used to host all the testing tools and carry out all the tasks needed to run tests.
5757

58-
## Migrating from VSTest
58+
## See also
5959

60-
In addition to the steps specific to your test framework, you need to update your test infrastructure to accommodate to `Microsoft.Testing.Platform`.
61-
62-
### `dotnet test`
63-
64-
Command line options of `dotnet test` are divided into 2 categories: build related arguments and test related ones.
65-
66-
The build related arguments are passed to the `dotnet build` command and as such don't need to be updated for the new platform. Build related arguments are listed below:
67-
68-
- `-a|--arch <ARCHITECTURE>`
69-
- `--artifacts-path <ARTIFACTS_DIR>`
70-
- `-c|--configuration <CONFIGURATION>`
71-
- `-f|--framework <FRAMEWORK>`
72-
- `-e|--environment <NAME="VALUE">`
73-
- `--interactive`
74-
- `--no-build`
75-
- `--nologo`
76-
- `--no-restore`
77-
- `-o|--output <OUTPUT_DIRECTORY>`
78-
- `--os <OS>`
79-
- `-r|--runtime <RUNTIME_IDENTIFIER>`
80-
- `-v|--verbosity <LEVEL>`
81-
82-
The test related arguments are VSTest specific and so need to be transformed to match the new platform. The following table shows the mapping between the VSTest arguments and the new platform:
83-
84-
| VSTest argument | New platform argument |
85-
|-----------------|-----------------------|
86-
| `--test-adapter-path <ADAPTER_PATH>` | Not supported |
87-
| `--blame` | Not supported |
88-
| `--blame-crash` | `--crashdump` requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump) |
89-
| `--blame-crash-dump-type <DUMP_TYPE>` | `--crashdump-type` requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump) |
90-
| `--blame-crash-collect-always` | Not supported |
91-
| `--blame-hang` | `--hangdump` requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump) |
92-
| `--blame-hang-dump-type <DUMP_TYPE>` | `--hangdump-type` requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump) |
93-
| `--blame-hang-timeout <TIMESPAN>` | `--hangdump-timeout` requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump) |
94-
| `--collect <DATA_COLLECTOR_NAME>` | Depends on the data collector |
95-
| `-d\|--diag <LOG_FILE>` | `--diagnostic` |
96-
| `--filter <EXPRESSION>` | Depends upon the selected test framework |
97-
| `-l\|--logger <LOGGER>` | Depends on the logger |
98-
| `--results-directory <RESULTS_DIR>` | `--results-directory <RESULTS_DIR>` |
99-
| `-s\|--settings <SETTINGS_FILE>` | Depends upon the selected test framework |
100-
| `-t\|--list-tests` | `--list-tests` |
101-
| `-- <RunSettings arguments>` | `--test-parameter` (provided by [VSTestBridge](microsoft-testing-platform-extensions-vstest-bridge.md)) |
102-
103-
> [!IMPORTANT]
104-
> Before specifying any `Microsoft.Testing.Platform` arguments, you need to add `--` to separate the `dotnet test` arguments from the new platform arguments. For example, `dotnet test --no-build -- --list-tests`.
105-
106-
### `vstest.console.exe`
107-
108-
If you are using `vstest.console.exe` directly, we recommend replacing it with the `dotnet test` command.
109-
110-
### Test Explorer
111-
112-
When using Visual Studio or Visual Studio Code Test Explorer, you might need to enable the support for the new test platform.
113-
114-
#### Visual Studio
115-
116-
Visual Studio Test Explorer supports the new test platform starting with version 17.14. If you are using an earlier version, you might need to update your Visual Studio to the latest version.
117-
118-
#### Visual Studio Code
119-
120-
Visual Studio Code with C# DevKit supports the new test platform.
121-
122-
### Azure DevOps
123-
124-
When using Azure DevOps tasks, you might need to update your pipeline to use the new test platform.
125-
126-
#### VSTest task
127-
128-
If you're using the [VSTest task](/azure/devops/pipelines/tasks/reference/vstest-v3) in Azure DevOps, you can replace it with the [.NET Core task](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2).
129-
130-
#### .NET Core task
131-
132-
If you're using the [.NET Core task](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2), no changes are needed.
60+
- [Migration guide from VSTest to Microsoft.Testing.Platform](./migrating-vstest-microsoft-testing-platform.md)
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
---
2+
title: Migration guide from VSTest to Microsoft.Testing.Platform
3+
description: Learn how to migrate from VSTest to Microsoft.Testing.Platform
4+
author: Youssef1313
5+
ms.author: ygerges
6+
ms.date: 09/15/2025
7+
---
8+
9+
# Migration guide from VSTest to Microsoft.Testing.Platform
10+
11+
In this article, you'll learn how to migrate from VSTest to Microsoft.Testing.Platform.
12+
13+
## Opt-in to use Microsoft.Testing.Platform
14+
15+
The first step in the migration is to opt-in to using Microsoft.Testing.Platform.
16+
17+
For all test frameworks, add `<OutputType>Exe</OutputType>` to all test projects in the solution. After that, follow the framework-specific guidance.
18+
19+
### MSTest
20+
21+
Microsoft.Testing.Platform is supported by MSTest starting with 3.2.0. However, we recommend updating to the latest available MSTest version.
22+
23+
To opt-in, add `<EnableMSTestRunner>true</EnableMSTestRunner>` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file.
24+
25+
> [!NOTE]
26+
> When using MSTest.Sdk, Microsoft.Testing.Platform is used by default, unless `<UseVSTest>true</UseVSTest>` is specified.
27+
28+
### NUnit
29+
30+
Microsoft.Testing.Platform is supported by NUnit3TestAdapter starting with 5.0.0.
31+
32+
To opt-in, add `<EnableNUnitRunner>true</EnableNUnitRunner>` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file.
33+
34+
### xUnit.net
35+
36+
Microsoft.Testing.Platform is supported starting with xunit.v3.
37+
38+
To opt-in, add `<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file.
39+
40+
## `dotnet test`
41+
42+
### Opt-in for .NET 9 SDK and earlier
43+
44+
In .NET 9 SDK and earlier, there is no *native* support for Microsoft.Testing.Platform for `dotnet test`. However, we provide support that is built on top of VSTest infrastructure. To use that, add `<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>` under a `PropertyGroup` in [`Directory.Build.props`](/visualstudio/msbuild/customize-by-directory) file.
45+
46+
> [!IMPORTANT]
47+
> When running Microsoft.Testing.Platform support in this mode, you need to add `--` to separate the `dotnet test` arguments from the new platform arguments. For example, `dotnet test --no-build -- --list-tests`.
48+
49+
### Opt-in for .NET 10 SDK and later
50+
51+
Starting with .NET 10 SDK, there is *native* support for Microsoft.Testing.Platform. To use it, you must specify the test runner as `Microsoft.Testing.Platform` in *global.json*:
52+
53+
```json
54+
{
55+
"test": {
56+
"runner": "Microsoft.Testing.Platform"
57+
}
58+
}
59+
```
60+
61+
> [!IMPORTANT]
62+
> In this mode, the extra `--` is no longer used.
63+
64+
### Update `dotnet test` invocations
65+
66+
Command line options of `dotnet test` are divided into 2 categories: build related arguments and test related ones.
67+
68+
The build related arguments are irrelevant to the test platform and as such don't need to be updated for the new platform. Build related arguments are listed below:
69+
70+
- `-a|--arch <ARCHITECTURE>`
71+
- `--artifacts-path <ARTIFACTS_DIR>`
72+
- `-c|--configuration <CONFIGURATION>`
73+
- `-f|--framework <FRAMEWORK>`
74+
- `-e|--environment <NAME="VALUE">`
75+
- `--interactive`
76+
- `--no-build`
77+
- `--nologo`
78+
- `--no-restore`
79+
- `-o|--output <OUTPUT_DIRECTORY>`
80+
- `--os <OS>`
81+
- `-r|--runtime <RUNTIME_IDENTIFIER>`
82+
- `-v|--verbosity <LEVEL>`
83+
84+
The test related arguments are VSTest specific and so need to be transformed to match the new platform. The following table shows the mapping between the VSTest arguments and the new platform:
85+
86+
| VSTest argument | New platform argument |
87+
|-----------------|-----------------------|
88+
| `--test-adapter-path <ADAPTER_PATH>` | Not relevant for Microsoft.Testing.Platform |
89+
| `--blame` | Not relevant for Microsoft.Testing.Platform |
90+
| `--blame-crash` | `--crashdump` (requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump)) |
91+
| `--blame-crash-dump-type <DUMP_TYPE>` | `--crashdump-type` (requires [Crash dump extension](./microsoft-testing-platform-extensions-diagnostics.md#crash-dump)) |
92+
| `--blame-crash-collect-always` | Not supported |
93+
| `--blame-hang` | `--hangdump` (requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump)) |
94+
| `--blame-hang-dump-type <DUMP_TYPE>` | `--hangdump-type` (requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump)) |
95+
| `--blame-hang-timeout <TIMESPAN>` | `--hangdump-timeout` (requires [Hang dump extension](./microsoft-testing-platform-extensions-diagnostics.md#hang-dump)) |
96+
| `--collect <DATA_COLLECTOR_NAME>` | Depends on the data collector |
97+
| `-d\|--diag <LOG_FILE>` | `--diagnostic` |
98+
| `--filter <EXPRESSION>` | Depends upon the selected test framework |
99+
| `-l\|--logger <LOGGER>` | Depends on the logger |
100+
| `--results-directory <RESULTS_DIR>` | `--results-directory <RESULTS_DIR>` |
101+
| `-s\|--settings <SETTINGS_FILE>` | Depends upon the selected test framework |
102+
| `-t\|--list-tests` | `--list-tests` |
103+
| `-- <RunSettings arguments>` | `--test-parameter` (provided by [VSTestBridge](microsoft-testing-platform-extensions-vstest-bridge.md)) |
104+
105+
#### `--collect`
106+
107+
`--collect` is a general extensibility point in VSTest for any data collector. The extensibility model of Microsoft.Testing.Platform is different and there is no such centralized argument to be used by all data collectors. With Microsoft.Testing.Platform, each data collector can add its own command-line option. For example, running Microsoft CodeCoverage through VSTest can be similar to the following:
108+
109+
```dotnetcli
110+
dotnet test --collect "Code Coverage;Format=cobertura"
111+
```
112+
113+
With Microsoft.Testing.Platform, this becomes:
114+
115+
```dotnetcli
116+
dotnet test --coverage --coverage-output-format cobertura
117+
```
118+
119+
> [!IMPORTANT]
120+
> As explained earlier, when using Microsoft.Testing.Platform with the VSTest-based `dotnet test`, extra `--` is needed before the arguments intended to be passed to the platform.
121+
> So, this becomes `dotnet test -- --coverage --coverage-output-format cobertura`.
122+
123+
#### `--filter`
124+
125+
`--filter` is the VSTest-based filter. This is supported by MSTest and NUnit even when running with Microsoft.Testing.Platform. However, for xUnit.net, this is no longer supported when running with Microsoft.Testing.Platform. You must migrate from the VSTest-based filter to the new filter support in xunit.v3 which is provided using the following command-line options:
126+
127+
- `--filter-class`
128+
- `--filter-not-class`
129+
- `--filter-method`
130+
- `--filter-not-method`
131+
- `--filter-namespace`
132+
- `--filter-not-namespace`
133+
- `--filter-trait`
134+
- `--filter-not-trait`
135+
- `--filter-query`
136+
137+
For more information, see [Microsoft.Testing.Platform documentation for xUnit.net](https://xunit.net/docs/getting-started/v3/microsoft-testing-platform) and [Query Filter Language for xUnit.net](https://xunit.net/docs/query-filter-language).
138+
139+
#### `--logger`
140+
141+
What was usually referred to as "logger" in VSTest is referred to as "reporter" in Microsoft.Testing.Platform. In Microsoft.Testing.Platform, logging is explicitly for diagnosing purposes only.
142+
143+
Similar to `--collect`, `--logger` is a general extensibility point in VSTest for any logger (what we call reporter in the context of Microsoft.Testing.Platform). Each Microsoft.Testing.Platform reporter is free to add its own command-line option, and as such there is no centralized command-line option similar to VSTest's `--logger`.
144+
145+
One of the very commonly used VSTest loggers is the TRX logger. This was usually called as follows:
146+
147+
```dotnetcli
148+
dotnet test --logger trx
149+
```
150+
151+
With Microsoft.Testing.Platform, this becomes:
152+
153+
```dotnetcli
154+
dotnet test --report-trx
155+
```
156+
157+
> [!IMPORTANT]
158+
> In order to use `--report-trx`, you must have `Microsoft.Testing.Extensions.TrxReport` NuGet package.
159+
>
160+
> [!IMPORTANT]
161+
> As explained earlier, when using Microsoft.Testing.Platform with the VSTest-based `dotnet test`, extra `--` is needed before the arguments intended to be passed to the platform.
162+
> So, this becomes `dotnet test -- --report-trx`.
163+
164+
#### `--settings`
165+
166+
VSTest's `--settings` is used to specify a RunSettings file for the test run. RunSettings isn't supported by the core Microsoft.Testing.Platform and was replaced by a more modern [`testconfig.json`](./microsoft-testing-platform-config.md) configuration file. However, MSTest and NUnit still support the old RunSettings when running Microsoft.Testing.Platform and `--settings` is still supported.
167+
168+
## `vstest.console.exe`
169+
170+
If you are using `vstest.console.exe` directly, we recommend replacing it with the `dotnet test` command.
171+
172+
## Test Explorer
173+
174+
When using Visual Studio or Visual Studio Code Test Explorer, you might need to enable the support for Microsoft.Testing.Platform.
175+
176+
### Visual Studio
177+
178+
Visual Studio Test Explorer supports Microsoft.Testing.Platform starting with version 17.14. If you are using an earlier version, you might need to update your Visual Studio to the latest version.
179+
180+
### Visual Studio Code
181+
182+
Visual Studio Code with C# DevKit supports Microsoft.Testing.Platform.
183+
184+
## Azure DevOps
185+
186+
When using Azure DevOps tasks, you might need to update your pipeline to use Microsoft.Testing.Platform, depending on which task you use.
187+
188+
### VSTest task
189+
190+
If you're using the [VSTest task](/azure/devops/pipelines/tasks/reference/vstest-v3) in Azure DevOps, you can replace it with the [.NET Core task](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2).
191+
192+
### .NET Core CLI task
193+
194+
1. If you have custom `arguments` passed to the task, this needs to follow the same guidance as the `dotnet test` migration guidance.
195+
1. If you're using the [DotNetCoreCLI](/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2) task without opting-in the native Microsoft.Testing.Platform experience for .NET 10 SDK and later via `global.json` file, you need to set the task `arguments` to correctly point to the results directory it used to point to, as well as requested TRX report. For example:
196+
197+
```yml
198+
- task: DotNetCoreCLI@2
199+
displayName: Run unit tests
200+
inputs:
201+
command: 'test'
202+
arguments: '-- --report-trx --results-directory $(Agent.TempDirectory)
203+
```

docs/navigate/devops-testing/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ items:
237237
href: ../../core/testing/microsoft-testing-platform-faq.md
238238
- name: Comparison with VSTest
239239
href: ../../core/testing/microsoft-testing-platform-vs-vstest.md
240+
- name: Migration guide from VSTest to Microsoft.Testing.Platform
241+
href: ../../core/testing/migrating-vstest-microsoft-testing-platform.md
240242
- name: Configure the test platform
241243
href: ../../core/testing/microsoft-testing-platform-config.md
242244
- name: Extensions

0 commit comments

Comments
 (0)