TeamCity Cloud 2023.09 Help

Manually Configuring Reporting Coverage

If you run .NET tests using NUnit, MSpec or .NET Process Runner runners or run NUnit tests via supported tasks of MSBuild or NAnt runners, you can turn on coverage collection in the TeamCity web UI for the specific runner.

For other cases, when the .NET code coverage is collected by the build script and needs to be reported inside TeamCity (for example, Rake, or if you run NUnit tests via a test launcher other than TeamCity NUnit Test Launcher), there is a way to let TeamCity know about the coverage data.

Make sure the build script actually collects the code coverage according to the coverage engine documentation.

Report the collected data to TeamCity via Build Script Interaction.

First, the build script needs to let TeamCity know details on the coverage engine with the "dotNetCoverage" message.
Then, the build script can issue one or several "importData" messages to import the actual code coverage data files collected.
As a result, TeamCity will display coverage statistics and an HTML report for the coverage.

Configuring Code Coverage Engine

Use the following service message template:

##teamcity[dotNetCoverage <key>='<value>' <key1>='<value1>' ...]

where key is one of the following:

For dotCover (optional):

Key

Description

dotcover_home

The full path to the dotCover home directory to override the bundled dotCover.

For NCover 3.x:

Key

Description

Sample value

ncover3_home

Full path to the NCover installation directory.

The path to the NCover3 installation directory

ncover3_reporter_args

Arguments for the NCover report generator.

Set //or FullCoverageReport:Html:{teamcity.report.path} or another NCover commandline argument

For NCover 1.x:

Key

Description

Sample value

ncover_explorer_tool

Path to NCoverExplorer.

Path to NCoverExplorer

ncover_explorer_tool_args

Additional arguments for NCover 1.x.

ncover_explorer_report_type

Value for /report: argument.

1

ncover_explorer_report_order

Value for /sort: argument.

1

For PartCover:

Key

Description

Value

partcover_report_xslts

Write xslt transformation rules one per line (use |n as separator) in the following format: file.xslt=>generatedFileName.html.

file.xslt=>generatedFileName.html

Importing Coverage Data Files

To pass an XML report generated by a coverage tool to TeamCity, in your build script use the following service message:

##teamcity[importData type='dotNetCoverage' tool='<tool_name>' path='<path_to_the_results_file>']

where tool_name can be dotcover, partcover, ncover or ncover3.

Last modified: 10 November 2021