NCover Documentation
Docs  ›  Legacy  ›  How-To  ›  Advanced Reporting Features

NCover 3.0 shipped with a new tool designed to extend the reporting functionality of NCover 2.0 and make NCover easier to integrate into custom build processes. That tool is called NCover.Reporting.exe, and while it's easy to create simple reports with it, there are several advanced features (Minimum Coverage Threshold, Satisfactory Coverage Thresholds, and Filters) that require more explanation.

Minimum Coverage Thresholds

Available only in NCover Complete, minimum coverage thresholds let you set and enforce minimum acceptable coverage percentages for every coverage metric supported by NCover. Minimum coverage thresholds are a simple yet powerful way to enforce corporate policy, promote best practices, and guarantee code coverage.

By default, no minimum coverage thresholds are set. Once minimum coverage thresholds are set however, NCover.Reporting applies them to the coverage data, and reports any element that fails to meet a threshold, as well as which threshold caused it to fail. Thresholds are applied only to the type specified in their Type field. Should two or more thresholds apply to the same element, the element will fail if it fails any threshold, and will pass only if no threshold fails it. If multiple thresholds aren't met, the element will be listed as failed for each threshold that fails it.

When any element fails a minimum coverage threshold, NCover.Reporting prints the displayed element and the threshold that failed it on the console. Once all failed elements have been displayed, NCover.Reporting exits with a return code of 3 to indicate that it failed because some minimum coverage thresholds were not met.

Syntax

For descriptions of how to send minimum coverage thresholds to NCover.Reporting.exe, consult the following documentation:

Examples

The following threshold will fail the project if every method in the project hasn't been called.

//mc MethodCoverage:100

This threshold fails any namespace that has a maximum Cyclomatic Complexity greater than 60.

//mc CyclomaticComplexity:60:Namespace

This threshold fails any class ending in "Test" if all of its methods haven't been executed (one way to fail the build if every test hasn't been executed).

//mc MethodCoverage:100:Class:".*Test$"

Satisfactory Coverage Thresholds

Available only in NCover Complete, satisfactory coverage thresholds let you set acceptable coverage percentages to a value more realistic than 100%, without failing the build when that acceptable percentage isn't met. Although 100% coverage is ideal, it is often very difficult to reach for any decent sized, moderately complex project, especially if the project wasn't tested as it was developed. Satisfactory coverage thresholds let you respond to that reality and set reasonable coverage goals for any element in your project, from an overall percentage for the entire project down to acceptable percentages for individual classes.

In NCover 3.0, satisfactory coverage thresholds can be set for any of the coverage metrics that NCover supports, for any element in the project (except for methods) and for the project itself. By default, the satisfactory threshold for every element is set to 100%, but that can be overridden by setting the satisfactory coverage for the project to some other value, like 70%. The satisfactory percentage for any element can be overridden by creating a satisfactory threshold for that particular element, or for every element of that type. Note that satisfactory thresholds are not inherited by an element's children. That is, if a class's satisfactory coverage is 70%, the satisfactory coverage for its methods is still 100%, unless the satisfactory coverage for the methods is overridden by another threshold.

Syntax

For descriptions of how to send satisfactory coverage thresholds to NCover.Reporting.exe, consult the following pages:

  • [Command Line Syntax](/support/docs/v3/ref/3-0/ncover-reporting/command-line/build-server#sct)
  • [MSBuild Syntax](/support/docs/v3/ref/3-0/ncover-reporting/msbuild/build-server#sct)
  • [NAnt Syntax](/support/docs/v3/ref/3-0/ncover-reporting/nant/build-server#sct)
  • [Config file Syntax](/support/docs/v3/ref/3-0/ncover-reporting/configuration/build-server#sct)

Examples

The following threshold sets the overall satisfactory coverage for the project to 65%.

//sct SymbolCoverage:65

This threshold sets the overall satisfactory method coverage for the project to 80%.

//sct MethodCoverage:80

This threshold sets the satisfactory branch coverage for classes to 77%.

//sct BranchCoverage:77:Class

These thresholds set the satisfactory coverage for all classes to 50%, and set the satisfactory coverage for critical classes to 95%.

//sct SymbolCoverage:50:Class
//sct SymbolCoverage:95:Class:project\.criticalnamespace\..*

Filters (Post-Coverage Exclusions)

Post-coverage exclusions, or filters, let you tweak the presented data in each report after NCover has already gathered coverage data. Filters let you gather all coverage data in one execution of NCover and then create reports based on sub-sections of that data. For example, you could create individual reports on each assembly, or group assemblies into larger components and create reports for each component, all without running NCover again. Filters become even more useful when combined with satisfactory and minimum coverage thresholds.

In NCover Classic, only Exclude filters are supported, but NCover Complete supports both Exclude and Include Filters. When an element matches a Filter, that element and its children are marked excluded and do not affect the coverage percentages of the element's parent. Filters can exclude/include any element from the entire project to an individual method, but by default everything is included. Include filters are the inverse of Exclude filters in that if an element doesn't match an include filter, it is excluded.

Syntax

For descriptions of how to send filters to NCover.Reporting.exe, consult the following pages:

  • [Command Line Syntax](/support/docs/v3/ref/3-0/ncover-reporting/command-line/build-server#cf)
  • [MSBuild Syntax](/support/docs/v3/ref/3-0/ncover-reporting/msbuild/build-server#cf)
  • [NAnt Syntax](/support/docs/v3/ref/3-0/ncover-reporting/nant/build-server#cf)
  • [Config file Syntax](/support/docs/v3/ref/3-0/ncover-reporting/configuration/build-server#cf)

Examples

This filter excludes all assemblies that end with "Test"

//cf "\*Test":Assembly

These filters excludes all properties.

//cf "\*get\_\*":Method
//cf "\*set\_\*":Method

This filter excludes all assemblies that don't begin with "myproject".

//cf "myproject\*":Assembly:False:True

This filter excludes all classes that end with "ORM".

//cf "\*ORM":Class

If you still need technical assistance, we can help:

Submit A Support Ticket