NCover Documentation

Migrating Your Build Server Coverage From NCover 3

Covering Your Build

Then

Build server integration with NCover 3 meant adding a call to NCover Console to your build script with a task or exec telling NCover to profile your test runner and gather the coverage data.

Now

Now, the NCover Service monitors test runners without interfering with these processes at all. As our lead developer likes to put it, "NCover stays out of the way."

NCover means no configuring code coverage tools or plug-ins.

From Code Central, you can monitor any number of build servers and/or desktops remotely and administer a repository of all their coverage data. Code Central can collect coverage data if installed on the build sever, or remotely using Collector. A Collector installed on the build server and connected to Code Central will gather coverage data every time your tests run and automatically send the results to Code Central.

The key to profiling any build with NCover is in profiling the right process.

If you're running MSTest in your Sonar build, then you set up an NCover project to monitor qtagent. If you're running NUnit, you set up a project to monitor nunit-agent.

The build platform isn't as important as the process that's running your unit tests.

Creating a Code Central Project

From the Home view of the Code Central, click Add New to open the "Create a New Project" window.

General Settings

From the "General Settings" tab, name the project and then use an Exe or Regex match rule to specify the test runner you want to monitor.

For example, the Exe file path option for covering NUnit would be "C:\Program Files(x86)\NUnit 2.5.10\bin\net-2.0".

The Regex option would be simply "nunit-agent", since the regex isn't case-sensitive.

If you have a Collector linked to Code Central, your projects will be automatically synced and set to Enabled by default.

Pre-Coverage Filter

Then

NCover could include or exclude attributes, assemblies, files, methods, and types at runtime by using regular expressions, as specified in the Project Options of the Explorer, or on the NCover Console command line.

Now

The runtime include/exclude functionality of NCover 3x has been integrated into NCover's Pre-Coverage Filter.

NCover can include or exclude attributes, assemblies, files, methods, and types at runtime by using regular expressions, as specified in NCover's Pre-Coverage Filter.

You can profile only the code you care about and shorten collection times by specifying what assemblies Collector should or shouldn't be profiling.

Collector will gather coverage on assemblies loaded by the test runner, but you don't usually want to collect coverage on third-party DLLs.

  1. Click the to add a new filter.

  2. Create a Name

  3. Add a Description (optional).

Filter Rules have the following configurable parameters:

Include or Exclude

Type - Module, Namespace, Class, Method, Attribute, Document Path, Branch Coverage, Sequence Point Coverage, Max Complexity Percentage and Max Complexity.

Condition - Matches, Starts With, Ends With, Contains, and Regex.

Value

Using the Microsoft Active Accessibility module as an example, a filter rule to exclude that code would look like this:

You can also create a filter to include only the code you care about, and ignore everything else, by specifying your assemblies with an include rule:

Thresholds

Then

Thresholds in NCover 3 were set for each project in Project Settings.

Now

NCover reports coverage statistics with color coding based on the thresholds provided in these settings, which are set with some reasonable default values when you create a project.

You can reset these values at any time by clicking on Reset to defaults.

Collecting Coverage

Once you've installed a Collector on your build server to profile your tests, connect it to Code Central and it will automatically pull down the pre-configured project settings from Code Central.

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

The new USE command for the NCover service will print environment changes needed for coverage collection to be assigned exclusively to one of your coverage projects.

From the command prompt, the USE command prints out the SET statements that you need to incorporate into your build process. Then, you can manually set those environment values in your build scripting.

The next time the process you've defined in the Code Central project is run on a QA machine, developer's desktop, or a build server, Collector will automatically gather coverage and send it to Code Central, where you can view and analyze all coverage results.

If you still need technical assistance, we can help:

Submit A Support Ticket