-
Notifications
You must be signed in to change notification settings - Fork 0
NCoverReport Task
The NCoverReportTask allows you to run verify minimum code coverage and get more detailed reports for your Continuous Integration server, through NCover 3’s NCover Reporting app.
Here is an example of how to use the NCoverReportTask to run a full coverage report and verify symbol, branch, method, and cyclomatic complexity coverage, using a coverage.xml file that was produced by ncoverconsoletask.
desc "Run a sample NCover Report to check code coverage"
ncoverreport :coveragereport => :ncoverconsole do |ncr|
ncr.command = "Tools/NCover-v3.3/NCover.Reporting.exe"
ncr.coverage_files "coverage.xml"
fullcoveragereport = NCover::FullCoverageReport.new
fullcoveragereport.output_path = "codecoverage/report"
ncr.reports fullcoveragereport
ncr.required_coverage(
NCover::SymbolCoverage.new(:minimum => 90),
NCover::BranchCoverage.new(:minimum => 90, :item_type => :Class),
NCover::MethodCoverage.new(:minimum => 100)
)
ncr.required_coverage NCover::CyclomaticComplexity.new(:maximum => 30, :item_type => :Class)
end
The following configuration options can be used to change the report that is produced, and the code coverage metrics that are checked.
This is the location of the NCover.Reporting.exe file that will be executed. If you don’t provide this, the task will fail with an error message:
NCoverReport.command cannot be nil.This is an array of .xml coverage files that were produced by running ncoverconsoletask.
The NCoverReportTask supports configuration via an external YAML file, including auto-configuration with a “ncoverreport.yml” file. For more information, see the yamlconfig page.
This is an array of reports that you want to run against the specified coverage files. You can run multiple reports in a single execution of NCover.Reporting, by appending them to the array or replacing the array entirely.
fullcoveragereport = NCover::FullCoverageReport.new
fullcoveragereport.output_path = "codecoverage/report"
ncr.reports fullcoveragereport
summaryreport = NCover::SummaryReport.new
summaryreport.output_path = "codecoverage/summary/summary-report.html"
ncr.reports summaryreport
The only reports that are supported at the moment are the FullCoverageReport and the SummaryReport. Both of these reports are only available in HTML format.
The output_path is assumed to be a folder that will contain all of the needed files for the report. If you specify a .html file as in the SummarReport example above, this specific .html file will be written as the main report file.
Both of the reports support configuration via an external YAML file, including auto-configuration with a “fullcoveragereport.yml” or “summaryreport.yml” file. For more information, see the yamlconfig page.
This setting allows you to specify the required level of code coverage for the various metrics that NCover supports. The example above shows all four of the supported metrics: Symbol, Branch, Method, and CyclomaticComplexity.
Each of these three coverage types should have a minimum level of coverage specified. If none is specified, zero (0) is assumed, which will allow any level of coverage to pass. If a minimum level is specified above zero (0), then any failure to reach this minimum requirement will cause the NCoverReportTask to fail the build.
Each of the coverage types allows you to specify a specific focus of how the coverage is determined. The default, “:View”, aggregates all coverage data into a single value and reports on it directly.
The valid options for item_type are:
- :View
- :Namespace
- :Module
- :Class
The CyclomaticComplexity coverage lets you specify the maximum complexity allowed in the coverage data (determined by the item_type). If a the actual CyclomaticComplexity of any specified item_type is greater than the maximum specified, the NCoverReportTask will fail.
The following examples illustrate the different ways of setting up a required_coverage option
ncr.required_coverage(
NCover::BranchCoverage.new(:minimum => 90, :item_type => :Class),
NCover::SymbolCoverage.new(:minimum => 90)
)
cc = NCover::CyclomaticComplexity.new
cc.maximum = 30
cc.item_type = :Class
ncr.required_coverage cc
This task supports configuration via an external YAML file. For more information, see the yamlconfig page.
This task supports additional command line options, including a .parameters collection for passing in options that are not directly supported. For more information, see the commandline task options documentation.
- Build-Server Integration
- Command Line Task Options
- Configuration
- Custom Tasks
- Logging Options
- Sample Usages
- Task Arguments and Rakefile Parameters
- YAML Configuration
- ASP.NET Compiler - ASP.Net website compiler
- Assembly Info Generator - generate assembly info dynamically
- CSC - C# compiler
- Exec - Execute arbitrary cmd
- Fluent Migrator - Run FluentMigrator on migration library
- ILMerge - Merge dll/exe-s together
- MSBuild and XBuild - Compile a .sln-file or a MsBuild xml-file
- MSpec - Test using MSpec (machine.specifications)
- MSTest - Test using Microsoft Test Framework
- NAnt - Run a NAnt script
- NChurn - Calculate per-file churn
- NCover Console - Run NCover for tests/library
- NCover Reports - Generate a report from a coverage run
- NDepend - Run NDepend to check static code metrics
- NuGet Install - Install NuGet packages
- NuGet Pack - Create NuGet packages
- NuGet Push - Push NuGet packages to official MS repo
- NuGet Publish - Publish NuGet packages
- NUnit - Test using NUnit
- NuSpec - Generate a NuSpec file
- Output - File copying and template expansion
- PLink - SSH into a remote computer and run a command
- SQLCmd - Run a SQL command as a part of your build process
- UnZip - Unzip a directory
- XBuild - Run XBuild (will be merged into MsBuild)
- XUnit - Test using XUnit
- Zip - Zip a directory or files
- Edit the Wiki Locally - How to edit the wiki without using Github's interface
- How to Build Albacore
- How to Contribute
