In this section:
Table of Contents |
---|
Overview
Anchor | ||||
---|---|---|---|---|
|
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 scopeRun VSTest Tests with Coverage
- executes unit tests in the tested scope, and collects coverage information
SeeConfiguring Test Configurations for details about specifying a test configuration.
Info | ||
---|---|---|
| ||
|
Examples
Your command line may resemble the following:
Running tests without collecting coverage information
Code Block dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests" -report "C:\Report"
Running tests and collecting coverage information
Code Block dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests with Coverage" -report "C:\Report"
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:
Code Block |
---|
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.
Code Block |
---|
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.:
Code Block |
---|
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.:
Code Block |
---|
dottestcli.exe -solution "C:\Devel\FooSolution\FooSolution.sln" -config "builtin://Run VSTest Tests" -testTagFilter "req=12345,6789" -testTagFilter "fr=abcd" |