TeamCity Cloud 2024.12 Help

NCover

TeamCity supports code coverage with NCover (1.x and 3.x) for NUnit tests run via TeamCity NUnit test runner, which can be configured in one of the following ways: web UI, TeamCity NUnit Test Launcher, NUnit for MSBuild, NUnit for MSBuild, NUnit for NAnt Build Runner.

Important Notes

  • To launch coverage, NCover and NCoverExplorer should be installed on the agent where the coverage build will run.

  • You don't need to make any modifications to your build script to enable coverage.

  • You don't need to explicitly pass any of the NCover/NCoverExplorer arguments to the TeamCity NUnit test runner.

  • NCover supports .NET Framework 2.0 and 3.5 started under x86 platform (NCover 3.x also supports x64 platform and works with .NET Framework 4.0). Make sure, you use have specified the same platform both for NCover and NUnit.

Configuring NCover 1.x

Make sure your NUnit tests run under x86.

To configure NCover 1.x:

  1. While creating/editing Build Configuration, go to the Build Steps page.

  2. Add one of the build steps that support NCover (.NET Process Runner, MSBuild, MSpec, NAnt, NUnit), configure unit tests.

  3. Select NCover (1.x) in .NET coverage tool.

  4. Set up the NCover options — refer to the description of the available options below.

Option

Description

Path to NCover

Specify the path to NCover installed on the build agent, or use %system.ncover.v1.path% to refer to the autodetected NCover on the build agent.

Path to NCoverExplorer

Specify the path to NCoverExplorer on the build agent.

Additional NCover Arguments

Type additional arguments to be passed to NCover.

Assemblies to Profile

Specify newline-separated assembly names (without paths and extensions), or leave this field blank to profile all assemblies.
Equivalent to //a NCover.Console option.

Exclude Attributes

Specify the classes and methods with defined .NET attribute(s) to be excluded from the coverage statistics.
Equivalent to //ea NCover.Console option.

Report Type

Select the report type. For the details, refer to NCoverExplorer documentation.

Sorting

Select the preferred sorting option. For the details, refer to NCoverExplorer documentation.

Additional NCoverExplorer Arguments

Specify additional arguments to be passed to NCoverExplorer. Do not enter here the output path for the reports, nor specify arguments, for which there are corresponding options in the UI.

Configuring NCover 3.x

Make sure you use have specified the same platform both for NCover and NUnit.

To configure NCover 3.x:

  1. While creating/editing Build Configuration, go to the Build Steps page.

  2. Add one of the build steps that support NCover (.NET Process Runner, MSBuild, MSpec, NAnt, NUnit), configure unit tests.

  3. Select NCover (3.x) in .NET coverage tool.

  4. Set up the NCover options — refer to the description of the available options below.

Option

Description

Path to NCover 3

Specify the path to NCover. Alternatively, use %system.ncover.v3.x86.path% or %system.ncover.v3.x64.path% to refer to the autodetected NCover 3 on the build agent.

Run NCover under

Select the preferred platform to run the coverage under — x86 or x64. Make sure the selected platform agrees with the one used for NUnit tests.

NCover Arguments

Specify NCover arguments, i.e. assemblies to profile and coverage tool specific arguments. Do not enter here arguments, which can be specified in the UI, nor enter here output path for generated reports and NCover process parameters. Use //ias.* to get coverage of all assemblies.

NCover Reporting Arguments

Specify additional NCover reporting arguments, except for the output path. Use or FullCoverageReport:Html:{teamcity.report.path} to get the report.

Reporting NCover Results Manually

If .NET code coverage is collected by the build script and needs to be reported inside TeamCity (for example, Rake, or if you run tests via a test launcher other than TeamCity NUnit Test Launcher), there is a way to let TeamCity know about the coverage data. Read more in Manually Configuring Reporting Coverage.

Last modified: 18 September 2024