In this section:

Running Unit Tests with VSTest

VSTest 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 NUnit Tests

You can execute NUnit Tests by running one of the following built-in configurations:

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

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 NUnit Tests" -report "C:\Report" 
  • Running tests and collecting coverage information

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


All files associated with NUnit integration are shipped in the [INSTALL_DIR]\integration\NUnit-2.6.3 directory. 

Running MSTest Tests

You can execute NUnit Tests by running one of the following built-in configurations:

  • Execute MSTests - executes MSTest tests in the tested scope
  • Execute MSTests with Coverage - executes MSTest tests in the tested scope, and collects coverage information


  1. MSTest must be integrated with dotTEST to run MSTest tests. If you did not integrate with MSTest during installation, you can run Deploy.exe in the MSTest integration directory: [INSTALLATION_DIR]\integration\MSTest\Deploy.exe.
  2. Run one of the built-in MSTest configurations and extend your dottestcli.exe command to include the build script that invokes mstest.exe:

    dottestcli.exe -solution "FooSolution.sln" -config "builtin://Execute MSTests with Coverage" -report "Report" -- "Run_tests.bat"

    The -- separator indicates the end of the dotTEST command line; arguments following -- from a command line that is invoked by dottestcli.exe.

In the above example, dotTEST launches the Run_tests.bat script and listens to all MSTests executed in the script as it runs. Unit test results are collected and code coverage is measured for FooSolution.sln.

  • No labels