Covering Your Build Server

Collecting Code Coverage On Your Build Server With NCover

NCover On Your Build Server

Start collecting coverage on your build server following these three steps

NCover Code Central allows you to monitor any number of build servers and test machines and collect coverage data. Code Central can collect coverage directly if it is installed locally on the build server or it can connect to any machine with Collector installed and collect coverage remotely.

Step 1 - Create a Project

Your NCover project is where your code coverage results will be sent and displayed in the NCover GUI. Whether you are planning to collect coverage locally with Code Central, or remotely with Collector, you need to create your new project within Code Central and give your project a name.

On a build server, your project will typically be set to collect coverage on NUNit or MSTest, although any testing tool can be used and the process for setting up your project is similar.

Once you have created your new project, select "Edit Match Rules" and add a new match rule.

  • For NUnit, add a match rule of
    Match type="Regex", Process matching="nunit-agent."
  • For MSTest, add a match rule of
    Match type="Regex", Process matching="qtagent."

If you are using Code Central to collect coverage locally, you can also use Auto-Configure if you are unsure of your testing tool.

Save the project and you are ready to build your NCover Run command.

Step 2 - The "NCover Run" Command

Since it's likely that you have more than one project on your build server,having a Code Central project set up to simply monitor the Nunit agent would gather a confusing variety of data on unrelated projects.

The NCover Run command allows NCover to:

  • Collect data from the covered process.
  • Send the coverage results to the project you specify..
  • Summarize the coverage results and generates links to the Coverage Summary html report.

The NCover Run command provides a variety of options that allow you to specify build Ids, return error codes, output a coverage summary to the console, register the NCover profiler DLLs and define the working directory..

Confirm NCover Run is producing the desired results from the command line prior to running it from a build script.

Step 3 - Integrate Into Your Build Scripts

The final step to completely automate coverage collection is to integrate the NCover Run command from above into your build script.

If you have any additional questions about using Code Central in your build environment, please contact us online.

.NET Code Coverage Solutions For Improving Code Quality