Saturday, 15 January 2011

Creating project code coverage with PartCover and NUnit

Since my last posts ‘Integrating PartCover with Visual Studio 2005’ and ‘Integrating PartCover with Visual Studio 2008’ a lot of things changed and improved. PartCover project got itself a new home and now targeting .Net 4.0 Framework. NUnit testing framework also made a lot of improvements. In this post I am going to show how to run code coverage for a test project with NUnit console runner and PartCover browser. I will base it on my EnvMan project.

Getting PartCover and Nunit to run

First of all you need to download and install PartCover from Github project server. After installation you will find PartCover browser manual and PartCover console manual, which are very useful for understanding of rules creation and PartCover parameters.
Start PartCover Browser.
image
Select File>Run Target. It will open ‘Run Target Settings Window’
image
Click Browse buttons to select nunit-console.exe  and working directory for running NUnit. Working arguments should have “/noshadow” and a full path with the test project name or NUnit project name. “/noshadow” will make NUnit not to create shadow copies of the files and will allow PartCover to load source files in the browser. In EnvMan project I have NUnit project file which has two assemblies in it. In the rules window enter
+[*EnvMan*]*
which means (+) add rule where include any assembly which has EnvMan in its name and any namespace in these assemblies. After this you can click start to run tests. Don’t forget to save xml configuration file for future use.

Inspecting code coverage

Congratulations! You can now inspect the results by using Views>View Coverage Details.
image

1 comment:

  1. Good Blog and your articles are interesting...!

    DevRabbit is helping the start ups and large businesses in accelerating their growth through cutting edge technology by leveraging Mobile App Development for iPhone and Android, Cloud Solution, Web Application Development & Big data analytics solutions, Digital Marketing services. DevRabbit is a Xamarin Consulting Company.

    ReplyDelete