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

Running and Debugging Tests

  • 2 minutes to read

Use one of the following approaches to run tests:

  • From the Visual Studio Menu bar.

    Use the CodeRush | Test menu to run selected test(s) or all tests in the solution.

    CRR_Testing_RunFromMenu

  • From the CodeRush Visualize toolbar.

    Use the CodeRush Visualize toolbar's commands to run tests and debug them.

    CRR_VisualizeToolbar

  • From the Test Runner window.

    Click the CodeRush | Windows | Test Runner menu item to open the Test Runner window.

    CRR_VisualizeToolbar

    If your project contains multiple frameworks, you can run tests for all target frameworks or in a selected framework in the Test Runner.

    CRR_Testing_TestRunner

    You can also group tests, search for tests, filter tests by status, and analyze their results.

    CRR_Testing_TestRunner

    If the Test Runner is disabled, use the Enable link to activate it.

    CRR_Testing_TestRunner

    NOTE

    The Run All command takes filtering into account. This command runs all tests shown in the tests tree when the Test Runner applied filtering.

  • From the Code Editor.

    If a test is parsed and ready to run, CodeRush marks the Test and TestFixture attributes with the test-tube icon.

    CRR_CodeEditor_Test

    Use one of the following ways to run tests:

    • Select an active target framework (for multi-framework projects).

      CRR_Testing_TestRunner

    • Click the test-tube icon to open the drop-down test runner menu and click Run test.

      CRR_Testing_TestRunner

    • Place the caret within a test and press Ctrl+T or Ctrl+R.

    To run a single test case of a parameterized test, click a test icon and choose an option from the Run test, or Run test with coverage sub menu. CodeRush shows failed tests at the top of the sub menu.

    RunSingleTestCase

    You can also use the same approach to run a test for a particular descendant of the current class.

  • From the Solution Explorer.

    Use the solution explorer's context menu to run tests in a document.

    CRR_Testing_RunFromSolutionExplorer

    CodeRush runs tests for all target frameworks in multi-framework projects.

NOTE

You can use the Test Runner to run MS Test unit tests in Visual Studio 2019 RC

Debugging a Test

  • Place the caret within the test.

  • Press Ctrl + T, Ctrl + D (Test -> Debug)

CodeRush runs the test with the debugger. You can stop the test on break points and use watch windows. This allows you to setup a test for a particular situation and then observe how your code behaves in that scenario.

Alternatively, you can click the Test icon to reveal the test context menu and choose Run test and Debug test from this menu.

RunSingleTestCase