dotCover 2016.3 Help

Visualizing Code Coverage

ReSharper | Cover | Toggle Code Highlighting
Ctrl+Alt+K H
ReSharper_ToggleHighlighting

To visualize coverage and test results data, dotCover can highlight statements in the current snapshot right in Visual Studio editor.

To visualize code coverage in the editor

  1. Open the snapshot that you want to analyze in the Coverage Results Browser window or in the Coverage area of the Unit Test Sessions window/ Continuous Testing Session window .
  2. Click Highlight code /help/img/dotnet/2016.3/ThemedIcon.Highlighting.Screen.[Gray].png on the toolbar of the window where the current snapshot is open.
  3. dotCover will highlight code in all assemblies that are included into the current coverage snapshot (see the left gutter):
    /help/img/dotnet/2016.3/dotCover_highlighting.png
  4. To disable highlighting of the current snapshot, press Ctrl+Alt+K H or choose ReSharper | Cover | Toggle Code Highlighting in the main menu

If you switch between several snapshots in the Coverage Results Browser window or in the Coverage area of the Unit Test Sessions window/ Continuous Testing Session window , the highlighting does not switch automatically. To switch the highlighting for a particular snapshot, click Highlight code /help/img/dotnet/2016.3/ThemedIcon.Highlighting.Screen.[Gray].png on the toolbar of the window where the current snapshot is open.

How the highlighting works

To indicate the state of the code statement, dotCover uses colored markers in the left gutter of Visual Studio:

Marker Description
/help/img/dotnet/2016.3/dc_highlighting_no_tests.png At least one statement in a line is not covered by unit tests.
/help/img/dotnet/2016.3/dc_highlighting_tests_pass.png All statements in a line are covered by unit tests. All tests pass.
/help/img/dotnet/2016.3/dc_highlighting_tests_fail.png All statements in a line are covered by unit tests. At least one test fail.

Note that right after you change the code, test results become outdated. In this case, a marker keeps its color but it becomes paler. The marker's tooltip shows the info about previous state as well:

/help/img/dotnet/2016.3/dc_highlighting_previous_state.png

If a line of code consists of a number of statements with different coverage results, dotCover will highlight the line taking into account only the "worst" result. For example, if tests for the first statement pass, but fail for the second, dotCover will highlight the line with the red color. Or, if one statement is covered by some failing tests and another statement is not covered at all, the marker will be grey:

/help/img/dotnet/2016.3/dc_highlighting_multiple.png

How to navigate to covering tests

To continue exploring code coverage, you can navigate to covering tests and/or locate code items in the coverage tree.

See Also

Last modified: 3 April 2017