Wednesday, May 11, 2005

NCover Code Coverage Tool

NCover is a code coverage tool for .NET. Unfortunately, NCover is actually 2 totally different coverage tools that share the same name. Neither one seems to be very mature, and people seem to be split on which one is better. They were designed to produce the same result, a code coverage report. But, they both work in very different ways. I don't think there is any hope for collaboration.

The best solution to the naming conflict I've seen to date is naming one NCover@SF and the other NCover@GDN.

NCover@SF is NCover hosted at SourceForge. This version of NCover uses instrumentation to get coverage results. Copying the original and instrumenting the copy is suggested. It includes functionality to deinstrument your code after the tests have been run, but in practice you'll likely delete all temporary code after test completion. I've successfully used it on a .NET 1.1 project and a .NET 2.0 project. NCover@SF runs as a NAnt task and is fairly easy to set up. The documentation is minimal and even wrong in 1 place, and the project website is not the best. However, the simplicity of using the tool makes up for these drawbacks.

NCover@GDN is NCover hosted at NCover.org; however, in the past this version of NCover was hosted at GotDotNet, thus the name. NCover@GDN uses the .NET Framework profiler API to monitor an application's execution. When a method is loaded by the CLR, NCover@GDN retrieves the IL and replaces it with instrumented IL code. NCover does not change your original IL code, it simply inserts new code to update a visit counter at each sequence point. After the .NET process shuts down, the profiler outputs statistics to a file in the current directory. I've not used NCover@GDN, but some of my co-workers are successfully using it. I've been told that it only works for .NET 1.1 and not .NET 2.0.

1 comment:

  1. NCover@GDN actually does support .NET 3.5 SP1
    v2.1+ are guaranteed to support it, and v1.5.8 supports it as well, albiet w/ some interesting results for generics, extension methods, anonymous methods, and delegates.

    ReplyDelete

Note: Only a member of this blog may post a comment.