dotCover 2018.1 Help

Analyze Coverage of Unit Tests (Basic Scenario)

The most basic scenario of using dotCover is measuring how much of your code do tests cover. Baseline conditions are as follows. You have a solution opened in Visual Studio. Code in the solution is covered with some unit tests. The task is to understand how much of the code is covered.

To analyze coverage of tests in an application

  1. Choose ReSharper | Unit Tests | 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.
    unit test explorer howto
  2. In the Unit Test Explorer window, select the tests whose coverage you want to analyze. If you want to analyze all tests, select the top-level node in the tree. Note that you can limit coverage scope by using coverage filters.
  3. Click the ThemedIcon JetBrainsDotCoverPresentationVsResourcesUnitTestingCoverageCover Screen Gray Cover Unit Tests button. This will run a normal unit tests session but dotCover will collect coverage data in the background. Test results will be shown in real time in the newly opened Unit Test Sessions window. Coverage results (how tests cover particular classes and methods in your code) will be shown in the Unit Test Coverage window.
    unit test sessions coverage
  4. If you want to see what tests exactly cover a particular class or method, select it in the Unit Test Coverage window and in the context menu choose Show Covering Tests.
    covering tests
  5. Visualize code coverage by clicking the ThemedIcon Highlighting Screen Gray Highlight code button.
    default coverage highlighting
    By default, coverage and test results are shown by markers in the left gutter of the Visual Studio editor: 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.
  6. The Unit Test Coverage window contains one more very useful metric. After you click dotCover hot spots icon Hot Spots, it will show you a "cloud" of potentially risky classes: the classes that have high cyclomatic complexity but are poorly covered with tests.
    hot spots coverage
Last modified: 16 April 2018