2

Say I have Test assembly (NUnit compliant) App.Test.dll and a library to be tested App.dll.

How do I get the code coverage analysis using PartCover and NUint?

Louis Rhys
  • 34,517
  • 56
  • 153
  • 221

3 Answers3

4

I concur. In my experiments (see blog post here: http://www.csharpcity.com/using-partcover-and-nunit-for-code-coverage/) I set up a project with an NUnit-complaint "AutomatedTest" project (which referenced NUnit's framework DLL and outputted a DLL full of test classes), and ran that through PartCover.

ashes999
  • 9,925
  • 16
  • 73
  • 124
  • I had a problem when I specified +[*]namespace* as the rule. +[Namespace]* works though – Louis Rhys Jul 28 '10 at 01:52
  • That's strange. The partcover doc swears that between square brackets is the project namespace. I start with +[*]* and then use whatever appears in the report :) – ashes999 Jul 28 '10 at 14:47
  • hmm when I tried +[*]* it reported the code coverage of nunit.. is there something I did wrong here? – Louis Rhys Aug 02 '10 at 08:19
  • I think you've already found my other thread on this. Yes, there seems to be a bug in PartCover. – ashes999 Aug 03 '10 at 17:23
2

The easiest way is to set up an NUnit test project (which runs App.Test.dll), then from PartCover call the NUnit console runner and pass the project name as a parameter. I have a blog post about it if you want to check that out.

(I haven't tried with .Net 4 or the latest versions of NUnit/PartCover but I'm assuming it's still the same).

Grant Crofton
  • 8,895
  • 5
  • 28
  • 38
2

It took me a while to figure out how get the source code markings. I had to put a /noshadow flag in the "Working Arguments". /noshadow prevents NUnit to make shadow copies of the files and will allow PartCover to load source files in the browser.

Then just click "Views->View Coverage Detail" after the run.

Torbjörn Nomell
  • 3,020
  • 2
  • 24
  • 20