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

Run code coverage analysis through NCover 3's NCover Console app.

desc "Run code coverage analysis"
ncoverconsole :coverage => [:build] do |cmd|
  nunit = NUnitTestRunner.new
  nunit.command = "path/to/nunit"
  nunit.assemblies = FileList["wildcard/path/to/assemblies"]
  nunit.options = ["/noshadow"]

  cmd.command = "path/to/ncoverconsole"
  cmd.output = {:xml => "path/to/output"}
  cmd.working_directory = "path/to/working/dir"
  cmd.test_runner = nunit
end

Required Parameters

Command

The location of the ncover.console executable. This can be an absolute or relative path, and should include the executable name.

command = "path/to/ncoverconsole"

Test Runner

NCover analyzes code that is being executed through a test runner. Test runners need to provide a get_command_line method that returns a string. The string returned from this method will be passed directly into this command.

Supported runners (tasks): nunit, mstest, mspec, xunit

nunit = NUnitTestRunner.new
nunit.command = "path/to/nunit"
nunit.assemblies = FileList["wildcard/path/to/assemblies"]
nunit.parameters = ["/noshadow"]

test_runner = nunit

Optional Parameters

Output

The coverage output type and location, relative to the working directory: :xml, :html.

output = {:xml => "path/to/output"}

If you do not provide an :xml file name, a "coverage.xml" file will be produced in the current folder. If you do not provide an :html file name, no report will be generated. If you only specify a folder and do not provide a specific file name for the report, a "fullcoveragereport.html" file will be generated.

Not providing a value means assigning an empty string or nil.

Working Directory

You can set the working directory that NCover will use, with this option. This will help to ensure that files produced by the running tasks will be placed into the specified folder.

working_directory = "out/coverage"

Include Assemblies & Exclude Assemblies

An array of assemblies to cover, using some basic pattern matching (see the docs for more details).

include_assemblies = ["MyProject.*", "MyOtherStuff.*"]
exclude_assemblies = ["DontUseThis.*"]

Or a Rake FileList

include_assemblies = FileList["wildcard/path/to/assemblies"]

Include Attributes & Exclude Attributes

An array of attributes to ignore in the coverage analysis. This can be assigned in the same way as the cover assemblies property, above. Namespaces, Classes, and Methods with an attribute that matches one of the regular expressions will be excluded from coverage.

include_attributes = ["foo", "bar"]
exclude_attributes = ["baz"]

Coverage

The types of coverage analysis: :Branch, :Symbol, :MethodVisits, :CyclomaticComplexity.

coverage = [:Branch]

No Registration

Do not temporarily register the NCover DLL for the current user.

no_registration

Guidance

(none)

Clone this wiki locally