Colin Bacon, web developer.

Adding code coverage data to NDepend is simple, so do it!

Adding code coverage data to NDepend is simple, so do it!

Generally, when we first use a new tool, we install it using the default or recommended settings. Then, as we start to use and understand the tool we tweak it. NDepend works brilliantly out of the box and comes into it's own once you learn and tweak it. However, the one thing I would recommend you set up straight away is test coverage data.

Why?

Test coverage in any project is important and adding code coverage data to NDepend is really simple to do. The main reasons why I think you should set it up are:

  1. All your analytic data is in one place
  2. You can use NDepend's powerful CQLinq to query and create rules on the coverage data
  3. NDepend will give you a more accurate technical debt rating

Adding coverage data

NDepend doesn't generate the raw data but imports data files from NCover, DotCover and Visual Studio.

The NDepend docs give you all the information on how to set up code coverage. I set it up with data from DotCover. To get the XML file from DotCover I ran Resharper > Unit Tests > Cover All Tests from Solution. Then from the coverage window I selected Export coverage report and Export to XML for NDepend...

Menu option for exporting coverage data for NDepend

From the top menu in Visual Studio select NDepend -> Coverage -> Import Code Coverage Data to import the XML file.

Menu option for importing coverage data

Now if you go to the dashboard you will see coverage data and better technical debt scoring.

Summary

As you can see adding test coverage data literally takes a few minutes to do. The benefits are; more accurate analysis data from NDepend and a greater understanding of the state of your project. Add to that you can now use CQLinq to query the data and create meaningful rules, there's no reason not to add it!