Skip to main content
A newer version of this page is available. .

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.

CRR_TestRunner_Grouping

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.

    CRR_Testing_RunFromMenu

  • From the CodeRush Visualize toolbar.

    If the CodeRush Visualize toolbar is active, use its commands to run tests and debug them.

    CRR_VisualizeToolbar

  • 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.

    CRR_Testing_TestRunner

    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.

    CRR_CodeEditor_Test

    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.

    RunSingleTestCase

    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.

    CRR_Testing_RunFromSolutionExplorer

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

CRR_IconPending

Test has not been executed

CRR_IconExplicit

Explicit test (is not executed

by the Run All button)

CRR_IconPassed

Test has passed

CRR_IconFailed

Test has failed

CRR_IconIgnored

Test was ignored

You can right-click a test to navigate to its code.

CRR_Testing_Results

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.

CRR_Testing_FailedCode

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.