Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

How-To's

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.

image description

Discover more