How to compare two code coverage sessions?

By Stephen Kellett
9 May, 2013

Recently we’ve had a flurry of customers wanting the ability to compare the code coverage of their application.

This sounded like a good idea so we asked these customers why they wanted to be able to compare different code coverage runs. The answers were varied:

  • I want to be able to take a known good baseline and compare it to a run with a regression in it.
  • I’ve inherited a legacy application and we want to understand the code paths for each given test.
  • I’ve inherited a legacy application and we know nothing about it. We’re testing it with appropriate input data and want to see which code executes.

For these customers being able to compare their code coverage runs is a big deal. Being able to compare your code coverage visually allows you to quickly and easily identify exactly the area to focus on, rather than just knowing that Session A has better coverage than Session B . It was such a compelling idea we’ve implemented code coverage comparison for all versions of Coverage Validator. This results in changes to the Session Manager and some new user interfaces.

Session Manager Dialog

Session Manager dialog

The Session Manager has an additional Compare… button which will display the Session Comparison dialog.

Session Comparison Dialog

Session compare dialog

The Session Comparison allows you to choose two sessions and then view the comparisons. Clicking the Compare… button will display the Code Coverage Comparison viewer.

Code Coverage Comparison Viewer

Session comparison results

The code coverage comparison viewer is split into two parts, separated by a splitter control.

The top part lists each file that is in each session being compared.

The bottom part displays the source code coverage for the baseline session and for the comparison session. You can choose to view all code coverage data for these files or to only view the files that are different between baseline and comparison sessions.

The display automatically selects the first file that contains code coverage differences and displays the baseline and comparison files in the bottom window at the location of the first difference in the file. As with our other code coverage displays the source code is highlighted to indicate which lines are visited/not visited and annotated so that you can determine line numbers and visit counts.

Comparing different executables?

It is possible to compare the code coverage results of two different executables.

This is useful if you want to compare two unit test runs.


Fully functional, free for 30 days