Code coverage gives you information on which lines of code have been executed and how long it took to execute them. It's of great benefit in larger code bases, since it's often difficult to be sure that every line of code (including all exception cases) have been properly exercised. Without code coverage, it's quite easy to ship an application containing large chunks that have never been run - a recipe for bugs and application failure. Some code coverage tools also offer profiling capabilities to establish which code is executed the most regularly: these routines are of course fertile ground for performance tuning.
We use code coverage extensively for many of our products - special code coverage builds are available during the development process that incorporate logging of this information for further analysis. But there's no built-in support in Visual Studio .NET for this feature, which is a pity.
To the rescue comes Stuart Richardson, one of my colleagues in the UK Solutions Development Centre, who's put together a tool that performs code coverage on .NET assemblies written in any language (it operates at the IL level). You can automate the tool via batch files, or as part of the build process using the new MSBuild engine that will ship in Whidbey. If you've got symbols and source available, the tool offers code colouring so you can see what has been executed.
|