JetBrains Rider 2021.3 Help

Working with unit tests in current document

Discover tests in the current document

JetBrains Rider discovers unit test classes and single unit tests of all supported frameworks right in the editor and adds the corresponding action indicators next to each item in the editor:

JetBrains Rider shows different indicators for unit tests in the editor

Test

The method is a unit test and you can run and debug it.

Test

The class is a unit test class and you can run and debug containing tests.

Passed

The unit test has passed during the last execution.

Passed

Tests in the unit test class have passed during the last execution.

Failed

The unit test has failed during the last execution.

Failed

At least one test in the unit test class has failed during the last execution.

Ignored

The unit test was ignored during the last execution.

Ignored

All tests in the unit test class were ignored during the last execution.

Run, debug, or cover tests in the current document

There are several ways to run, debug, or cover unit tests in the current document. You can use action indicators, main menu or shortcuts:

  • To run, debug, or cover a single test or all tests in a test class, click the action indicator next to it or set the caret at the test /test class and press Alt+Enter. In the action list, choose Run/Debug or Cover for a test or Run All/Debug All or Cover All for a test class.

    JetBrains Rider: Recognizing unit tests in the editor
  • Alternatively, you can use the Run Unit Tests Run Unit Tests Ctrl+;, R/ Debug Unit Tests Debug Unit Tests Ctrl+;, D or Cover Unit Tests Cover Unit Tests commands, which are also available in the main menu ( Tests) and in the context menu. These commands work differently depending on the caret position or selection in the editor:

    • To run, debug, or cover a single test or all tests in a test class, set the caret at the test/test class name, or anywhere inside its declaration in the editor .

    • To run several tests, select the desired tests in the editor .

    • To run all tests in the current file, either select all or set the caret outside test classes.

Whatever way you choose to run, debug, or cover tests, you will see the execution progress, results, and output in the Unit Tests window. If there is an open unit test session, the executed tests are added to that session. If there are no test sessions or the existing ones are locked, then a new tests session is created.

If necessary, you can always repeat execution or coverage analysis of the tests that you executed last by pressing Ctrl+;, T or choosing Tests | Repeat Previous Run in the menu.

You can also re-run tests that failed by pressing Ctrl+;, F or choosing Tests | Rerun Failed Tests in the menu.

Last modified: 07 April 2022