views:

410

answers:

4

Is there a free code coverage tool suitable for use with .NET 4 and NUnit that runs from the command line (and is thus suitable for use on a build server)?

Please note that any tools that require editions of Visual Studio higher than Professional are not appropriate in this case.

I am asking this question because I can't get NCover 1.5.8 to work with NUnit 2.5.5 on a .NET 4 C# app. I can run the unit tests, and I can generate a Coverage.Xml file, but it is empty - it contains no sequence points. After a lot of research, I have concluded that this is because NCover 1.5.8 simply doesn't work with .NET 4. However, if you know better, please feel free to answer this question from another user.

+2  A: 

There is PartCover And two forks of partcover,

Sharpcover here

And Partcover-fork here

All seem defunct. Not sure about .net 4 compatibility but partcover ran ok on 3.5 code. I'd love to see someone pick these up.

edit Add one more to the mix. With .net 4 coverage as the intent http://wiki.github.com/sawilde/partcover.net4/

nportelli
Added a link to a partcover fork for .net 4
nportelli
+1  A: 

NCover has held the code coverage niche for the .NET market for some time, probably since it first went commercial. I suspect the issue is that the old free version was compiled for .NET 2, and .NET 4 is sufficiently different the old NCover now won't work correctly.

For what it's worth, NCover 3 seems the most viable option. Admittedly not free, but the cost isn't too bad for the Classic version. I've been trialling it recently, and it's worked fine against a .NET 4 application. And it's much cheaper than a higher-end version of Visual Studio.

Grant Palin
... and with "NCover Loves Devs" offer it gets even cheaper: http://www.ncover.com/we_love_devs
The Chairman
@The Chairman: thanks for sharing that, what a deal!
Grant Palin
It appears that deal has expired.
Larry Fix
A: 

I think the short answer to this question is "No".

I found out that it is possible to get NCover 1.5.8 working with a bit of hacking* but it seems that there's nothing out there that's free that supports .NET 4. If you find otherwise, comment on this post or the question, and I'll happily accept a more appropriate answer.

(*) "The trick is to set the environment variable: COMPLUS_ProfAPI_ProfilerCompatibilitySetting=EnableV2Profiler"

-Jamie Cansdale

Damian Powell
Last link in my post someone is going for .net 4 coverage. http://wiki.github.com/sawilde/partcover.net4/
nportelli
+1  A: 

FYI: PartCover now supports .NET 4.0

Shaun Wilde