Skip to main content

Unit Testing Assistance

  • 3 minutes to read

You can use the Unit Test Runner tool for the following tasks:

The Unit Test Runner consists of two parts:

1) A test runner tool window - allows you to run tests for all target frameworks in multi-framework projects. You can also debug tests and analyze their results.

CRR_Testing_TestRunner

2) An in-editor UI - allows you to run tests from the code editor.

RunSingleTestCase

You can use the Unit Test Runner to group tests, search for tests, filter tests by status, and analyze their results.

CRR_Testing_TestRunner

For information on how to configure the Unit Test Runner, see the following topics:

Run/Debug Tests in Multi-Framework Projects

If your test project contains multiple target frameworks, the CodeRush Test Runner allows you to run or debug tests:

For all target frameworks

CRR_Testing_TestRunner

For a selected framework

CRR_Testing_TestRunner

Note

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

You can also select an active target framework in the code editor.

CRR_Testing_TestRunner

Then, you can run or debug tests for this selected framework.

CRR_Testing_TestRunner

If you use the “Run Tests” or “Debug Tests” item in Solution Explorer’s context menu, CodeRush runs or debug tests for all target frameworks.

CRR_Testing_RunFromSolutionExplorer

Note

The Unit Test Runner allows you to run and debug MSTest unit tests for Universal Windows Platform (UWP) applications.

XUnit’s Pretty Display Names for Test Cases

The Unit Test Runner can show the “pretty formatted” names for xUnit test cases in .NET Core projects.

CRR_Testing_RunFromSolutionExplorer

To support xUnit’s method display names, CodeRush uses the xUnit’s methodDisplay and methodDisplayOptions settings.

To enable this feature, make sure the “Collect tests from assemblies when opening a solution and rebuilding projects” option is activated on the Unit Testing | Test Runner options page.

CRR_Testing_RunFromSolutionExplorer

Discovering Tests

If your solution contains tests and the appropriate framework is referenced, the Unit Test Runner:

  • Discovers tests from source code and assemblies when you open a solution. The “Collect tests from assemblies when opening a solution and rebuilding projects” option is initially enabled in the Test Runner options page.

  • Marks the tests with an icon to the left of each test attribute.

  • Creates a tests tree in the Test Runner tool window.

Test Framework Support

The Unit Test Runner supports the following testing frameworks:

For details on how to set up the testing framework, refer to the following topic: Testing Framework Configuration.

Note

CodeRush Unit Test Runner supports running tests under SciTech Software’s .NET Memory Profiler. This third-party product allows you to use the Run Under Memory Profiler toolbar button (Icon_MemProfiler) to run tests designed to identify memory leaks and other memory usage issues.