Run and Debug Tests
- 2 minutes to read
Use one of the following approaches to run or debug unit tests:
Visual Studio Menu Bar
Open the CodeRush | Test menu and choose the corresponding menu item.
Note
You can restore the default CodeRush menu position in Visual Studio 2019 16.4 or later (the CodeRush menu is nested inside Visual Studio’s Extensions menu). Start Visual Studio, select Extensions -> Customize Menu…, uncheck the CodeRush item in Extensions Menu tab, and restart Visual Studio.
The CodeRush Visualize Toolbar
Use the CodeRush Visualize toolbar’s commands.
The Test Runner Window
Click the CodeRush | Windows | Test Runner menu item to open the Test Runner Window.
If the Unit Test Runner is disabled, click the Enable link to activate it.
If your project contains multiple frameworks, you can run tests or debug them for all target frameworks, or a selected framework in the Test Runner window.
You can use the Unit Test Runner to run/debug MS Test unit tests in Visual Studio 2019 RC and for Universal Windows Platform (UWP) applications. The screenshot below shows the Test Runner in UWP application:
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 or debug tests:
Option 1
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 or Debug test menu item.
Option 2
Place the caret inside a test method and press Ctrl+T,R or Ctrl+T,D.
To run a single test case of a parameterized test, click a test icon and choose an option from the Run test, Run test with coverage, or Debug test sub menu. CodeRush shows failed tests at the top of the sub menu.
You can also use the same approach to run/debug a test for a particular descendant of the current class.
The Solution Explorer
Use the solution explorer’s context menu to run/debug tests in a document.
CodeRush runs/debugs tests for all target frameworks in multi-framework projects.