New code coverage highlighting in dotCover 2016.3

After we released the initial continuous testing support in dotCover, the most popular response was “Cool, but this could be a lot more useful if highlighting was able to indicate test results.” Indeed, before 2016.3, dotCover’s highlighting was used only to indicate code coverage:

Code coverage highlighting in dotCover 2016.2 and earlier

dotCover 2016.3 finally addresses the issue. First, we got rid of colored backgrounds. Now, we use a small colored marker in the left gutter. Second and most important, we’ve completely changed the highlighting logic. Now, it not only shows whether a statement is covered by tests but also indicates test results.

dotCover 2016.3 code highlighting

The new highlighting is especially useful for continuous testing. You no longer need to keep the Continuous Testing Session window open: you run tests and see results instantly, right in the code:

Code coverage highlighting in dotCover 2016.3

Each marker’s tooltip shows you details on the number of tests, their state, and coverage session. Note that as soon as you change the code in any way, test results become outdated. In this case, a marker keeps its color but it becomes lighter. The marker’s tooltip continues to show details about the previous state:

Tooltip shows info about previous coverage state

How to quickly navigate to covering tests?

Just use the Ctrl+Alt+K,T shortcut. Alternatively,

  1. Click on a marker to see tests. The list with covering tests will appear.
  2. Double click on a particular test to navigate.

Navigate to covering tests

How to quickly debug failed tests?

Using the same tests list that appears by click on a marker!

First, you can quickly get stack trace data for any failed test:

Stack trace for failed tests

You can also instantly set a breakpoint for any statement that is covered by a failing test and then launch debugging:

Debug failed tests

What if there are multiple statements in a line?

If a line of code includes several statements with different coverage results, dotCover will highlight the line taking into account only the ‘worst’ result. For example, if tests pass for the first statement, but fail for the second, dotCover will highlight the line with red. If one statement is covered by some failing tests and another statement is not covered at all, the highlighting will be gray:

Multiple statements in a line

How to enable code coverage highlighting?

Nothing has changed in this regard. As usual, you can enable/disable the highlighting in the Unit Test Sessions window (Coverage tab) using the Highlight code button or the Ctrl+Alt+K,H shortcut.

Turn on code coverage highlighting

As usual, we invite you to try this new feature on your own. Download ReSharper Ultimate 2016.3 and let us know how it works for you.

This entry was posted in How-To's and tagged , , , . Bookmark the permalink.

12 Responses to New code coverage highlighting in dotCover 2016.3

  1. Cormac says:

    When you do a diff on a file prior to checking in can you see the code coverage indicators? I always find this important as you should be able to see that every modified line you check in is covered by a passing test. Some of the code coverage tools don’t show up when doing a diff in visual studio.

  2. Pingback: Dew Drop - January 19, 2017 (#2405) - Morning Dew

  3. Greg says:

    Nice functional features, but is there an option to get the old background highlighting back? I like that better.

  4. Joan Comas says:


    I installed ReSharper Ultimate 2016.3.2 on Visual Studio Ultimate 2013 12.0.40629.00 Update 5 with .NET 4.6.01055, opened a small solution and covered all tests. The Coverage tab in the Unit Test Sessions window shows the coverage nicely, but when I open any file, the code highlight says “Statement uncovered by tests in session All tests in Solution. Also, right clicking on a class with coverage on the Coverage Tree and clicking on Show covering tests says “Code is not covered by tests in session All tests from Solution”.

    I tried the same thing with Continuous testing with the same results.

    Then I switched Continuous testing off and the Coverage tab in the Unit Test Sessions window no longer shows percentages, everything’s 0%.

    Restarting Visual Studio fixed that.

    I tried clearing Resharper’s caches and restarting without success.

    Am I doing something wrong?

  5. Tom Gillen says:

    I am getting poor editor performance with this enabled, with scrolling feeling very clunky.

    Otherwise, this is brilliant!

Leave a Reply

Your email address will not be published. Required fields are marked *