NUnit and Microsoft.Testing.Platform
Overview
Microsoft.Testing.Platform (MTP) is the new platform for testing from Microsoft. Test projects can be run as executables, as with NUnitLite currently. There is no longer a test runner; the executable is the test runner.
It will take time to develop feature parity with NUnit's current system, and there are many historical factors to consider. But, the NUnit team recognizes that in the meantime, there needs to be a bridge between these two. In NUnit, the NUnit3TestAdapter contains what is necessary to run the MTP using the existing test runners.
This means we have two modes of MTP operation: either use the new platform but not as an executable, or use it as an executable too.
Changing a Project to Use MTP
To change a current test project to use MTP, you need to use version 5.0 or greater of the NUnit3TestAdapter.
Note that this version can run both with and without MTP, and you can easily switch between them by setting two project properties.
In a property group (use the top-level one), add the following two properties:
<EnableNUnitRunner>true</EnableNUnitRunner>
<OutputType>Exe</OutputType>
The first property, EnableNUnitRunner
, enables the MTP. The second enables it to also run as an executable (but it
doesn't prevent you from using it in Test Explorer or through dotnet test
.
Switching from VSTest to dotnet test
You can switch between VSTest
and dotnet test
using a property in your csproj (or Directory.Build.props):
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
See this article for more information.