Test Code Coverage with NCover

It is desirable to know test code coverage sometimes. It indicates quality and amount of tests and helps to ensure that TDD going right. This even could be one of the metrics for release acceptance (code coverage should be no less than 75%, for example).

NCover is a free tool for test code coverage metric generation (for .NET projects). It integrated pretty good with NUnit and within 10 minutes or so you may confugure it and get useful report.

Install NCover and NUnit and add ncover.console.exe and nunit-console.exe into PATH environment variable. Open comand prompt and to to the folder where your DLL with tests located. And just run the following command

> ncover.console /c nunit-console Tests.dll /a Project1;Project2;Project3

By the way, default stylesheet is very bad. You can get more better one here, Replace original Coverage.xslt with new in NCover folder, it will be copied each time when ncover runs.

If you use NAnt, you may add NCover report generation as a task.

One thought on “Test Code Coverage with NCover”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s