NCover Documentation
Docs  ›  Legacy  ›  Reference  ›  NAnt Extension

Please visit Covering Your Build Server for updated information.

NCover's NAnt extension makes it easy to measure coverage and generate coverage reports from your NAnt build scripts.

Loading The Extension

You'll need to load the NAnt tasks before you can use them. Use the <loadtasks> NAnt task to load them:

<loadtasks assembly="C:\Program Files\NCover\Build Task Plugins\NCover.NAntTasks.dll" />

The <ncover> Task

Use the <ncover> task to measure coverage with NCover from your NAnt build script.

Basic Usage

<target name="coverage">
  <ncover program="C:\Program Files\NCover\NCover.Console.exe"
{nunitPath}\nunit-console.exe"
      testRunnerArgs="TestAssembly1.dll TestAssembly2.dll"
      coverageFile="Coverage.xml" />
</target>

The above task runs NCover on the NUnit console test runner, giving it two test assemblies as arguments, and writes the resulting output to the file Coverage.xml.

Options

See the NCover.Console NAnt options for an exhaustive reference of the options available within the <ncover> NAnt task.

The <ncoverreporting> Task

Use the <ncoverreporting> task to generate reports, merge coverage files, and fail builds based on coverage thresholds.

Basic Usage

<target name="coverageReport">
  <ncoverreporting program="C:\Program Files\NCover\NCover.Reporting.exe">
    <coverageDataPaths>
      <include name="Coverage.xml" />
    </coverageDataPaths>
    <reports>
      <report reportType="FullCoverageReport" format="Html" outputPath="CoverageReports/" />
    </reports>
  </ncoverreporting>
</target>

The example above loads the coverage file named Coverage.xml and generates a full coverage report into the CoverageReports folder.

Options

See the NCover.Reporting NAnt Options for an exhaustive reference of the options available with the NCoverReporting MSBuild task.

If you still need technical assistance, we can help:

Submit A Support Ticket