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.
Configuring NCover 1.x
Make sure your NUnit tests run under x86.
To configure NCover 1.x:
While creating/editing Build Configuration, go to the Build Steps page.
Add one of the build steps that support NCover (.NET Process Runner, MSBuild, MSpec, MSTest, NAnt, NUnit), configure unit tests.
Select NCover (1.x) in .NET coverage tool.
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 |
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 new-line separated assembly names (without paths and extensions), or leave this field blank to profile all assemblies. Equivalent to |
Exclude Attributes | Specify the classes and methods with defined .NET attribute(s) to be excluded from the coverage statistics. Equivalent to |
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:
While creating/editing Build Configuration, go to the Build Steps page.
Add one of the build steps that support NCover (.NET Process Runner, MSBuild, MSpec, MSTest, NAnt, NUnit), configure unit tests.
Select NCover (3.x) in .NET coverage tool.
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 |
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. Please read more at Manually Configuring Reporting Coverage.