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.
From the CodeRush Visualize toolbar.
Use the CodeRush Visualize toolbar's commands to run tests and debug them.
From the Test Runner window.
Click the CodeRush | Windows | Test Runner menu item to open the Test Runner window.
If your project contains multiple frameworks, you can run tests for all target frameworks or in a selected framework in the Test Runner.
You can also group tests, search for tests, filter tests by status, and analyze their results.
If the Test Runner is disabled, use the Enable link to activate it.
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.
Use one of the following ways to run tests:
Select an active target framework (for multi-framework projects).
Click the test-tube icon to open the drop-down test runner menu and click Run test.
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.
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.
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.