Free Unit Testing Code Coverage with OpenCover and ReportGenerator


So you want to do development "right," you write unit tests and now want to see your code coverage? But you're not using a Visual Studio Enterprise?

Phil Fresle comes to the rescue, showing off how you can use a number of free projects to get your code coverage reports today...

OpenCover and ReportGenerator Unit Test Coverage in Visual Studio 2013 and 2015

The usual choices for getting code coverage metrics in Visual Studio is to buy the Enterprise version of Visual Studio or buy the dotCover third party tool, both of which are costly, especially if you are developing small applications yourself and want to check the coverage of your unit tests.

There is a free NuGet package for generating code coverage metrics called OpenCover, and together with another free NuGet package, ReportGenerator, can give you code coverage reports for free.

The problem I found, however, was the documentation available to get the tool working was less than adequate for my purposes and it took several hours of faff to get it working for me. To save you time and money I have documented my experience here.

The following were all referenced in the creation of this document:

I have tested that this works in Visual Studio 2013 Professional and Visual Studio 2015 Community Edition, with both MSTest and NUnit.

I assume you already have a solution with application project that you are testing with a test project, and where you are using NUnit for that testing that you have already included the NUnit NuGet package.

... [Click through to read the rest of the post]


OpenCover is a code coverage tool for .NET 2 and above (Windows OSs only - no MONO), with support for 32 and 64 processes and covers both branch and sequence points. OpenCover was started after attempts to make PartCover support 64-bit processes got just a little too complicated.

The latest releases can be downloaded from releases or from the OpenCover mirror site on bitbucket. Alternatively why not try the nuget package (this is the most popular).



OpenCover produces an XML output file that can be used to generate a graphical report. Thankfully you do not have to do that yourself as Daniel Palme has kindly added support for OpenCover to his Report Generator tool.

This the output from Report Generator for OpenCover.Framework.dll looks something like this.




ReportGenerator converts XML reports generated by OpenCover, PartCover, Visual Studio or NCover into human readable reports in various formats.


ReportGenerator converts XML reports generated by OpenCover, PartCover, Visual Studio or NCover into human readable reports in various formats.

The reports do not only show the coverage quota, but also include the source code and visualize which lines have been covered.

ReportGenerator supports merging several reports into one. It is also possible to pass one XML file containing several reports to ReportGenerator (e.g. a build log file).

The following output formats are supported by ReportGenerator:

  • HTML, HTMLSummary, HTMLChart
  • XML, XMLSummary
  • Latex, LatexSummary
  • TextSummary
  • CsvSummary
  • PngChart
  • Badges
  • Custom reports


Also available as NuGet package:




The Discussion

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.