|
| 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 | + ``` |
0 commit comments