A little challenge for you, what wrong with the title … ready … absolutely nothing. There are currently two open source products which ‘cover’ the same functionality and obviously have the same name … Ncover.
I wanted to use a code coverage tool integrated in the daily build process. The build process was created with the use of Nant, Nunit and CruiseControl.Net. Both versions of Ncover can be used with these tools.
The first Ncover tool has been moved from GotDotNet to www.ncover.org (latest release dec 2004). This version has no integration with Nant, but has a command line interface which can be used along with the Exec task from Nant to implement a code coverage in the daily build.
The second Ncover tool you can download at sourceforce (latest release jun 2004) This version integrates with Nant by using its own tasks. You’ll need 4 tasks to get the coverage of you’re tests. The creepy thing about this tool is that the ncover task has to ‘instrument’ you’re code to create some helpers for the coverage process.
Based on the ‘instrument’ issue I started with the first (www.ncover.org) Ncover tool. For each Nunit project within our solution I have created an Exec task to get a coverage of the code. Example:
commandline='/c "nunit-console.exe" "Project.nunit /xml=nunit-results.xml
/a AssemblyA;AssemblyB /o ncover-results.xml /l ncover.log'/>
You can parse the results with the standard coverage.xsl or with this alternative and it give’s you the coverage of the nunit tests within you’re solution. And of course we all have the following results:
See also a great tutorial for Ncover starters.