TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Manually Configuring Reporting Coverage

Last modified: 20 April 2023

If you run tests using NUnit, MSTest, 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 TeamCity web UI for the specific runner.

For other cases, when the .Net code coverage is collected by the build script and need to be reported inside TeamCity (for example, Rake, or if you run NUnit tests via test launcher other than TeamCity NUnit Test Launcher), there is a way to let TeamCity know about the coverage data. Communication is done via Build Script Interaction with TeamCity. First, the build script need to let TeamCity know details on the coverage engine with "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 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:

For NCover 3.x:

For NCover 1.x:

For PartCover:

Importing Coverage Data Files



To pass 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.