You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To enable MTP compatibility with the VSTest mode of `dotnet test`, add the following property to your project file (.csproj/.fsproj/.vbproj):
284
+
The way you enable MTP mode for `dotnet test` varies depending on what version of the .NET SDK you're using (meaning the version number that's printed when you run `dotnet --version` from your project folder).
285
+
286
+
### Using .NET SDK version 8 or 9
287
+
288
+
To enable `dotnet test` to run your tests using MTP instead of VSTest, add the following property to your project file (.csproj/.fsproj/.vbproj):
285
289
286
290
```xml
287
291
<PropertyGroup>
@@ -329,7 +333,59 @@ Test run summary: Failed! - bin\Debug\net8.0\MyFirstUnitTests.dll (net8.0|x64)
The same command line options available in the Microsoft Testing Platform command line experience (described in the table above) are also available for `dotnet test`. The command line options are passed after `--`. For example, to filter tests to a single class with the Microsoft Testing Platform `dotnet test` experience, you could run: `dotnet test -- --filter-class ClassName`. This includes command line options from any [Microsoft Testing Platform features](#additional-microsoft-testing-platform-features) you may add. _**Note:** These command line options are available for `dotnet test` regardless of whether you enable the Microsoft Testing Platform command line experience._
336
+
The same command line options available in the Microsoft Testing Platform command line experience (described in the table above) are also available for `dotnet test`. The command line options are passed after `--`. For example, to filter tests to a single class with the Microsoft Testing Platform `dotnet test` experience, you could run: `dotnet test -- --filter-class ClassName`. This includes command line options from any [Microsoft Testing Platform features](#additional-microsoft-testing-platform-features) you may add.
337
+
338
+
You can find additional configuration options for the Microsoft Testing Platform `dotnet test` integration here: [Microsoft.Testing.Platform mode of `dotnet test`](https://learn.microsoft.com/dotnet/core/testing/unit-testing-with-dotnet-test#microsofttestingplatform-mtp-mode-of-dotnet-test)
339
+
340
+
### Using .NET SDK version 10 or later
341
+
342
+
To enable `dotnet test` to run your tests using MTP instead of VSTest, add/edit the `global.json` file in the root of your solution with the following value:
343
+
344
+
```json
345
+
{
346
+
"test": {
347
+
"runner": "Microsoft.Testing.Platform"
348
+
}
349
+
}
350
+
```
351
+
352
+
Now when running `dotnet test`, your output should looks something like this:
353
+
354
+
```shell
355
+
$ dotnet test
356
+
Running tests from bin\Debug\net8.0\MyFirstUnitTests.dll (net8.0|x64)
from bin\Debug\net8.0\MyFirstUnitTests.dll (net8.0|x64)
371
+
Assert.True() Failure
372
+
Expected: True
373
+
Actual: False
374
+
at MyFirstUnitTests.UnitTest1.MyFirstTheory(Int32 value) in UnitTest1.cs:28
375
+
bin\Debug\net8.0\MyFirstUnitTests.dll (net8.0|x64) failed with 2 error(s) (158ms)
376
+
Exit code: 2
377
+
Standard output: xUnit.net v3 Microsoft.Testing.Platform Runner v3.1.0+03a071627b (64-bit .NET 8.0.22)
378
+
379
+
Test run summary: Failed!
380
+
total: 5
381
+
failed: 2
382
+
succeeded: 3
383
+
skipped: 0
384
+
duration: 254ms
385
+
Test run completed with non-success exit code: 2 (see: https://aka.ms/testingplatform/exitcodes)
386
+
```
387
+
388
+
The same command line options available in the Microsoft Testing Platform command line experience (described in the table above) are also available for `dotnet test`. For example, to filter tests to a single class with the Microsoft Testing Platform `dotnet test` experience, you could run: `dotnet test --filter-class ClassName`. Typing `dotnet test -?` from within your project folder will list all the available options (including built-in options, options provided by xUnit.net, and options from any [Microsoft Testing Platform features](#additional-microsoft-testing-platform-features) you have added).
333
389
334
390
You can find additional configuration options for the Microsoft Testing Platform `dotnet test` integration here: [Microsoft.Testing.Platform mode of `dotnet test`](https://learn.microsoft.com/dotnet/core/testing/unit-testing-with-dotnet-test#microsofttestingplatform-mtp-mode-of-dotnet-test)
0 commit comments