NUnit 2.5.6 + PartCover 2.0/4.0 = My Classes Not Shown
Summary: I can run unit tests and code-coverage, but the report only includes NUnit classes, not my application classes.
I have successfully used PartCover in the past. Not so this time. I tried the latest PartCover (4.0), downgraded to the next latest (2.0), both with NUnit 2.5.6.
I created a simple .NET 4.0 class library (also tried this with a web application that has a project that's a class library) with a single class in some namespace, and two test methods in another library in another class.
NUnit/PartCover installed correctly; 开发者_StackOverflow中文版I can run the NUnit tests both in NUnit, and through PartCover (I can see them running and saying "2 passed"), but the report only shows me NUnit namespaces. (Yes, I'm using +[] as my coverage rule.)
Any ideas? As much as I like NUnit, I'd like to see coverage for my own classes :o)
And I also tried aligning the test-DLL and code-DLL namespaces, to no avail.
Edit: I tried re-running my previously working code-covered sample from a year ago; all the tests run, but the actual project namespaces don't appear. There's a hint here, which seems to imply that it depends on the NUnit version you use: http://sourceforge.net/projects/partcover/forums/forum/605222/topic/3308367 (and yes, I already tried the appdomain-reporting checkbox)
I've tried NUnit 2.5.5.x and 2.5.6.x and both give me the same results.
Edit: It seems this fork of the official 4.0 version seems to work, albeit sporadically (google for PartCover fork, I can't add more hyperlinks)
Madness. Apparently, pressing Pause/Break on your keyboard after NUnit prints out the summary of total passed/failed, and waiting approximately one second for the second "CoreProfiler is turned off" message, makes it all work.
Surely, this cannot be the real solution. Sure, I can rig up a batch file that'll sleep ~1 second after executing NUnit, but this seems like a major hack.
The correct way to handle this is to add the required runtime to nunit's configuration. You will notice that NUnit is running in CLR 2.0 instead of 4.0. There are numerous answers to this question on SO, but I found this one first. Doing this alone fixed it for me. Note, your version of the runtime may be slightly different. You may need to confirm.
精彩评论