JetBrains Rider 2022.3 Help

Analyze Coverage of Unit Tests

The most basic scenario of using dotCover is measuring how much of your code is actually executed when you run unit tests. Baseline conditions are as follows: you have a solution opened in JetBrains Rider and code in the solution is covered with some unit tests. The task is to understand how much of the code is covered.

Analyze coverage of unit tests in a solution

  1. Choose View | Tool Windows | Unit Tests from the main menu. This will open the Unit Test Explorer tool window. Here you can take a look at how many tests are there in the solution.

    JetBrains Rider: Unit test explorer
  2. In the Unit Test Explorer window, select the test project or the tests whose coverage you want to analyze.

  3. To run coverage analysis for all tests, under Run All Tests, select Cover All Tests.

    To run coverage analysis only for the selected tests, under Run All Tests, select Cover Selected Unit Tests.

    This will run a regular unit tests session, but dotCover will collect coverage data in the background. dotCover will show test results in real-time in the newly opened session tab. Coverage results (how tests cover particular classes and methods in your code) will be shown in the Unit Test Coverage tool window.

    JetBrains Rider: Unit test session coverage

    For more information about unit tests sessions, refer to the dotCover documentation.

  4. Visualize code coverage by clicking Highlight code Highlight code in the Unit Test Coverage window.

    JetBrains Rider: Default coverage highlighting

    By default, coverage and test results are shown by markers in the editor gutter: a marker is red if any tests related to the current statement are failing, green if all tests are passing, and grey if there are no tests covering this statement.

Last modified: 07 December 2022