Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Microsoft.Testing.Platform
is a lightweight and portable alternative to VSTest for running tests in command line, in continuous integration (CI) pipelines, in Visual Studio Test Explorer, and in Visual Studio Code. In this article, you learn the key differences between the MSTest runner and VSTest.
Tests are executed in different ways depending on the runner.
VSTest ships with Visual Studio, the .NET SDK, and as a standalone tool in the Microsoft.TestPlatform NuGet package. VSTest uses a runner executable to run tests, called vstest.console.exe
, which can be used directly or through dotnet test
.
Microsoft.Testing.Platform is embedded directly into your test project and doesn't ship any extra executables. When you run your project executable, your tests run. For more information on running Microsoft.Testing.Platform tests, see Microsoft.Testing.Platform overview: Run and debug tests.
To familiarize yourself with Microsoft.Testing.Platform
and VSTest, it's helpful to understand the namespaces and NuGet packages that are used by each.
VSTest is a collection of testing tools that are also known as the Test Platform. The VSTest source code is open-source and available in the microsoft/vstest GitHub repository. The code uses the Microsoft.TestPlatform.*
namespace.
VSTest is extensible and common types are placed in Microsoft.TestPlatform.ObjectModel NuGet package.
Microsoft.Testing.Platform is based on Microsoft.Testing.Platform NuGet package and other libraries in the Microsoft.Testing.*
namespace. Like VSTest, the Microsoft.Testing.Platform
is open-source and has a microsoft/testfx GitHub repository.
Note
The Visual Studio Test Explorer supports the Microsoft.Testing.Platform protocol in the preview versions since 17.10 onward. If you run/debug your tests using earlier versions of Visual Studio, Test Explorer will use vstest.console.exe
and the old protocol to run these tests.
Microsoft.Testing.Platform uses a JSON-RPC based protocol to communicate between Visual Studio and the test runner process. The protocol is documented in the MSTest GitHub repository.
VSTest also uses a JSON based communication protocol, but it's not JSON-RPC based.
To disable the use of the new protocol in Test Explorer, you can edit your project to add the following property: <DisableTestingPlatformServerCapability>true</DisableTestingPlatformServerCapability>
.
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.
In addition to the steps specific to your test framework, you need to update your test infrastructure to accommodate to Microsoft.Testing.Platform
.
Command line options of dotnet test
are divided into 2 categories: build related arguments and test related ones.
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:
-a|--arch <ARCHITECTURE>
--artifacts-path <ARTIFACTS_DIR>
-c|--configuration <CONFIGURATION>
-f|--framework <FRAMEWORK>
-e|--environment <NAME="VALUE">
--interactive
--no-build
--nologo
--no-restore
-o|--output <OUTPUT_DIRECTORY>
--os <OS>
-r|--runtime <RUNTIME_IDENTIFIER>
-v|--verbosity <LEVEL>
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:
VSTest argument | New platform argument |
---|---|
--test-adapter-path <ADAPTER_PATH> |
Not supported |
--blame |
Not supported |
--blame-crash |
--crashdump requires Crash dump extension |
--blame-crash-dump-type <DUMP_TYPE> |
--crashdump-type requires Crash dump extension |
--blame-crash-collect-always |
Not supported |
--blame-hang |
--hangdump requires Hang dump extension |
--blame-hang-dump-type <DUMP_TYPE> |
--hangdump-type requires Hang dump extension |
--blame-hang-timeout <TIMESPAN> |
--hangdump-timeout requires Hang dump extension |
--collect <DATA_COLLECTOR_NAME> |
Depends on the data collector |
-d\|--diag <LOG_FILE> |
--diagnostic |
--filter <EXPRESSION> |
Depends upon the selected test framework |
-l\|--logger <LOGGER> |
Depends on the logger |
--results-directory <RESULTS_DIR> |
--results-directory <RESULTS_DIR> |
-s\|--settings <SETTINGS_FILE> |
Depends upon the selected test framework |
-t\|--list-tests |
--list-tests |
-- <RunSettings arguments> |
Not supported |
Important
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
.
If you are using vstest.console.exe
directly, we recommend replacing it with the dotnet test
command.
When using Visual Studio or Visual Studio Code Test Explorer, you might need to enable the support for the new test platform.
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.
Visual Studio Code Test Explorer supports the new test platform starting with version X.
When using Azure DevOps tasks, you might need to update your pipeline to use the new test platform.
If you're using the VSTest task in Azure DevOps, you can replace it with the .NET Core task.
If you're using the .NET Core task, no changes are needed.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
C# testing in Visual Studio - Training
Start testing your C# apps by using the testing tools in Visual Studio. Learn to write tests, use Test Explorer, create test suites, and apply the red, green, refactor pattern to write code.
Certification
Microsoft Certified: Power Platform Developer Associate - Certifications
Demonstrate how to simplify, automate, and transform business tasks and processes using Microsoft Power Platform Developer.
Documentation
Microsoft.Testing.Platform overview - .NET
Learn about Microsoft.Testing.Platform, a lightweight way to run tests without depending on the .NET SDK.
Microsoft.Testing.Platform FAQ - .NET
Get answers to frequently asked questions about Microsoft.Testing.Platform.
Use Microsoft.Testing.Platform with `dotnet test` - .NET
Learn how to run Microsoft.Testing.Platform tests through dotnet test.