In this section:

Overview 

You can execute your unit tests with or without collecting coverage information by running one of the VSTest built-in configurations. VSTest is an execution engine that can execute NUnit, MSTest, and xUnit tests. As a result, it allows you to execute tests from projects that use different testing frameworks in a single run. For example, if your Visual Studio solution contains two projects that use two different testing frameworks, NUnit and MSTest, you can run the tests in both projects in one run.

VSTest uses framework-specific test adapters to find and execute tests. If the tested scope includes multiple projects that use the same testing framework, ensure that the version of the adapter for this framework is consistent across all the projects.

Run one of the following built-in test configurations on the scope of analysis to execute your tests with VSTest:

  • Run VSTest Tests - executes unit tests in the tested scope
  • Run VSTest Tests with Coverage - executes unit tests in the tested scope, and collects coverage information

See Configuring Test Configurations for details about specifying a test configuration.

Running MSTest Tests with VSTest

  • To run MSTest V2 tests with VSTest, ensure that the test adapter is located in the tested project output directory.
  • Results of MSTest and MSTest V2 parameterized tests are accumulated and reported as a single test due to the MSTest framework limitations.

Examples

Your command line may resemble the following:

  • Running tests without collecting coverage information

    dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests" -report "C:\Report" 
  • Running tests and collecting coverage information

    dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests with Coverage" -report "C:\Report" 

Running MSTest Tests

We strongly recommend that you execute your MSTest test with the VSTest test configurations. The framework-specific test configurations are shipped with dotTEST for legacy purposes.

Specifying Test Scope Based on Issue Tracking Tags

You can limit the scope of test execution based on issue tracking tag associations made in the code. Add the -testTagFilter switch to specify the issue tracking tag type (e.g., test, req, fr, etc.) and ID using the following syntax:

dottestcli.exe <arguments> -testTagFilter <type>=<ID>

Refer to the Associating Tests with Development Artifacts section for details about associating tests with issue tracking IDs.

In the following example, only tests that have been associated with requirement ID 12345 will be executed.

dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests" -testTagFilter "req=12345"

You can specify multiple IDs in a comma-separated list for the same issue tracking tag, e.g.:

dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests" -testTagFilter "req=12345,6789"

You can also use multiple instances of the -testTagFilter switch to run tests for several issue tracking types, e.g.:

dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests" -testTagFilter "req=12345,6789" -testTagFilter "fr=abcd"

  • No labels