Skip to content
Henrik edited this page Aug 21, 2014 · 1 revision

Verify minimum code coverage and get more detailed reports for your CI build, through NCover 3's NCover Reporting app.

desc "Check code coverage stats"
ncoverreport :coveragereport => [:build, :coverage] do |cmd|
  cmd.command = "path/to/ncoverreport"
  cmd.coverage_files = ["path/to/coverage/file"]
  cmd.reports = [NCover::FullCoverageReport.new(:output_path => "out")]
  cmd.required_coverage = [NCover::BranchCoverage.new(:minimum => 90, :item_type => :Class)]
end

Required Parameters

Command

The location of the NCover.Reporting.exe executable.

command = "path/to/ncoverreport"

Coverage Files

An array of XML coverage files that were produced by the NCover console task.

coverage_files = ["path/to/coverage/file"]

Reports

The reports that you want to run against the specified coverage files: NCover::FullCoverageReport & NCover::SummaryReport.

reports = [
  NCover::FullCoverageReport.new(:output_path => "out")
]

Output Path

The path for this report.

:output_path => "out"

Report Type

The report type: :Html & :Xml. This is already set in the concrete report types provided.

:report_type => :Html

Required Coverage

The required level of code coverage: NCover::SymbolCoverage, NCover::BranchCoverage, NCover::MethodCoverage, and NCover::CyclomaticComplexity. Properties may be passed in the constructor as a hash parameter

required_coverage = [
  NCover::BranchCoverage.new(:minimum => 90, :item_type => :Class)
  NCover::CyclomaticComplexity.new(:maximum => 50, :item_type => :Class)
]

Minimum

The minimum code coverage to meet or the task will fail, the default is zero (0). Applicable for Symbol, Branch, and Method coverage.

:minimum => 90

Maximum

The maximum complexity allowed or the task will fail. Applicable only to Cyclomatic Complexity.

:maximum => 50

Item Type

How the coverage data is aggregated and reported: :View (default), :Namespace, :Module, Class. Applicable to all coverage types.

:item_type => :Class

Optional Parameters

Filters

Post-coverage exclusions for filtering the coverage results: NCover::AssemblyFilter, NCover::NamespaceFilter, NCover::ClassFilter, NCover::MethodFilter, & NCover::DocumentFilter.

filters = [
  NCover::AssemblyFilter.new(:filter => "myproject\\*")
]

Filter

The text, wildcard pattern, or regex content for the filter.

:filter => "myproject\\*"

Filter Type

The filter type: :exclude (default), :include (only in NCover Complete).

:filter_type => :exclude

Is Regex

Tells NCover if the filter data is a regexp: true or false (default).

:is_regex => true

Guidance

(none)

Clone this wiki locally