Running and Debugging Tests
- 3 minutes to read
The Unit Test Runner searches for unit tests (created using one of the supported frameworks) in the solution. Once the tests have been parsed, they are placed to the Test Runner window. You can filter the list of tests by entering a part of the test method name in the Search field. The Grouping menu allows you to choose the way the tests are grouped.
NOTE
You can run MS Test unit tests using Test Runner in Visual Studio 2019 RC
To execute the discovered tests, use one of the following approaches.
From the Visual Studio Menu bar.
Use the CodeRush | Test menu to run currently selected test(s) or all tests in the solution.
From the CodeRush Visualize toolbar.
If the CodeRush Visualize toolbar is active, use its commands to run tests and debug them.
From the Unit Test Runner window.
Open the Unit Test Runner window using the CodeRush | Windows | Test Runner menu item. This window displays all tests in the solution. You can group them, search for certain tests, filter tests by status, run tests and analyze their results.
NOTE
Test filtering affects the behavior of the Run All command. If you click Run All in the Unit Test Runner window, the filtered out tests will not be executed.
From the Code Editor.
If a test is parsed and ready to run, the Test and TestFixture attributes are marked with the test-tube icon to the left. Click this icon to open the drop-down test runner menu.
You can also execute a single test case of a parameterized test. Click a test icon and choose the desired option from the Run test, Debug test, or Run test with coverage submenu.
You can also execute a test for a particular descendant of the current class in a similar manner.
From the Solution Explorer.
You can run all tests in a document using its context menu.
After test execution is finished, the test status is instantly updated in the Test Runner window. A test can have one of the following statuses.
Status Icon | Description |
---|---|
Test has not been executed | |
Explicit test (is not executed by the Run All button) | |
Test has passed | |
Test has failed | |
Test was ignored |
You can right-click a test to navigate to its code.
To obtain detailed information on a failed test, select it and open the Details tab, or hover the mouse pointer over the appropriate icon in the code.
The Unit Test Runner enables you to analyze code coverage. Refer to the Code Coverage Calculation article to learn more about code coverage calculation abilities.