NCover Documentation

Please visit Covering NUnit for updated information.

The Gallio Project is an effort to provide a common, consistent interface for the numerous .NET testing frameworks available. This article explains how to get NCover working with the Gallio framework.

Covering Tests From The Command Line

Covering tests run with Gallio is quite simple. Take whatever working Gallio command line you have and put a call to ncover.console.exe in front of it. For example, if your working Gallio command line looks like this:

gallio.echo.exe testassembly1.dll testassembly2.dll

Then gathering coverage on your tests will look like this:

ncover.console.exe //pn "C:\program files\gallio\bin\gallio.echo.exe" testassembly1.dll testassembly2.dll

Covering Tests From NCover Explorer

Now that you have a working command line that gathers coverage with NCover and Gallio, setting up an NCover Explorer project just means transferring that data to the right fields in NCover Explorer's Project Configuration window, as in the screenshot below. The Working Folder field should be the directory your test assemblies are in.

Also, you will want to add the process name in the Output Options window.

A curiosity of the Gallio framework is that even though it installs in the x86 version of Program Files on x64 machines, the x64 version of NCover.Console must be used to gather coverage data from tests run with Gallio, so that even on x64 machines, there is no need to visit the NCover Path page. Close the Project Configuration window and click the green Run Coverage button to run NCover and start looking at coverage data!

Covering Tests From A Build Script

Well, now that you've set up a project in NCover Explorer, getting coverage from an automated build script is just a click away. Press the Script Helper button and select any of the tasks to have NCover Explorer generate the build script for you. The NAnt NCover task is shown below.

<!-- Generated by NCover Explorer at -->

<project name="NCoverCoverage" default="coverage" xmlns="">

<!-- TODO: Uncomment and add the full path to NCover.NAntTasks.dll if not in your path -->
<!-- TODO: Alternatively, remove this line if you have copied the .dll to your NAnt bin folder -->
<!-- < loadtasks assembly="NCover.NAntTasks.dll"/ > -->
<target name="coverage" description="Generate code coverage using NCover">
   <ncover program="C:\Dev\NCover\Main\Release\ncover.console.exe"
            testRunnerExe="C:\Program Files (x86)\Gallio\bin\Gallio.Echo.exe"
            testRunnerArgs="testassembly1.dll testassembly2.dll"
            projectName="run tests with gallio"    />

Plug the coverage target or the NCover task into your build script wherever it makes the most sense. If you would like to integrate your build script's results into your build server's interface, read one our articles describing how to integrate NCover into your build server.

If you still need technical assistance, we can help:

Submit A Support Ticket