Create NCover Reports

Reporting is critical to sharing code quality statistics with a team and with project stakeholders. Reporting on code coverage is also of huge benefit on continuous integration servers, where there would otherwise be no feedback from running NCover during the testing process. Reports can be generated with NCover either on the command line with the NCover Reporting Command Line tool, or through the reports tool in NCover Explorer. In this article we’ll walk you through creating reports with both tools, and give an overview of the reports available through NCover.

Generating Reports With NCover Explorer

The easiest way to generate a report with NCover is through NCover Explorer. Make sure that you have an NCover project loaded, and if you want trend graphs in your report, that you have a trends file loaded with your project. Then, choose Generate Reports from the toolbar.

ncover_generate_report_dialog

In the Generate Reports Dialog you can choose from over 20 different reports. Choose the report that you would like to run, whether you would like to generate the report as HTML or XML and the path where you would like the report saved, and click Generate Report. You can optionally have NCover Explorer open the report in your browser after it is generated by checking the Display after generation checkbox.

Generating Reports With The NCover Reporting Command Line Tool

When generating reports as part of an automated build or from a script, you’ll want to use the NCover.Reporting.exe Command Line Tool. You can learn more about the command line options that are available in the tool in the reference documentation, or by running it with the //? option. There are many options available, but for now we’ll look at the most frequent use cases.

To generate a report you’ll need a coverage file. You can generate a full html report with the following command line:

NCover.Reporting Coverage.xml //or FullCoverageReport //op "C:\Coverage Report"

This command line will generate a full coverage report based on the Coverage.xml coverage file in the directory C:\Coverage Report.

To include a graph of trends with your report, you’ll need a trends file. To generate a full html report with trends, use the //lt command line flag.

NCover.Reporting Coverage.xml //lt Trends.trends //or FullCoverageReport //op "C:\Coverage Report"

Command lines for the NCover Reporting Command Line Tool can get to be fairly complicated. Fortunately, your settings for the NCover.Reporting Command Line Tool can be stored to an XML file so that the same options can be used for subsequent runs. You can learn more about the NCover.Reporting Config File format here.

Available Report Types

Below you’ll find the name of each report, along with the option to pass to the NCover Reporting Command Line Tool to generate the report and a description of the report.

Name Command Line Identifier Description
Full Coverage Report FullCoverageReport The Full Coverage Report lets you browse through the full hierarchy of your project. It also includes a report of the largest uncovered sections of your code so that you can quickly and easily target them. Because this report generates several files, it expects a folder to be passed as as the report path when generating the report. The Full Coverage Report is only available as an HTML report.
Uncovered Code Sections Report UncoveredCodeSections The Uncovered Code Sections report highlights the largest segments of uncovered code in your project. The Uncovered Code Sections Report is only available as an HTML report.
Symbol Source Code Report SymbolSourceCode Create a report showing symbol coverage for source files.
Symbol Source Code Class Report SymbolSourceCodeClass Create a Source Code and Class symbol coverage coverage report.
Symbol Source Code Class Method Report SymbolSourceCodeClassMethod Create a Source Code, Class, and Method symbol coverage report
Method Source Code Report MethodSourceCode Create a report showing function coverage for source files.
Method Source Code Class Report MethodSourceCodeClass Create a Source Code and Class function coverage report.
Method Source Code Class Method Report MethodSourceCodeClassMethod Create a Source Code, Class, and Method function coverage report.
Symbol Module Report SymbolModule Create a Module symbol coverage report.
Symbol Module Namespace Report SymbolModuleNamespace Create a Module and Namespace symbol coverage report.
Symbol Module Namespace Class Report SymbolModuleNamespaceClass Create a Module, Namespace and Class symbol coverage report.
Symbol Module Namespace Class Method Report SymbolModuleNamespaceClassMethod Create a Module, Namespace, Class and Method symbol coverage report.
Symbol Cyclomatic Complexity Module Class Failed Coverage Top Report SymbolCCModuleClassFailedCoverageTop Create a Cyclomatic Complexity Module and Class coverage report showing the top items failing the build.
Symbol Cyclomatic Complexity Module Class Coverage Top Report SymbolCCModuleClassCoverageTop Create a Cyclomatic Complexity Module and Class coverage report.
Method Module Report MethodModule Create a Module function coverage report.
Method Module Namespace Report MethodModuleNamespace Create a Module, Namespace function coverage report.
Method Module Namespace Class Report MethodModuleNamespaceClass Create a Module, Namespace and Class function coverage report.
Method Module Namespace Class Method Report MethodModuleNamespaceClassMethod Create a Module, Namespace, Class and Method function coverage report.
Method Cyclomatic Complexity Module Class Failed Coverage Top Report MethodCCModuleClassFailedCoverageTop Create a Cyclomatic Complexity Module and Class function coverage report showing the top items failing the build.
Method Complexity Cyclomatic Module Class Coverage Top Report MethodCCModuleClassCoverageTop Create a Cyclomatic Complexity Module and Class function coverage report.

Should I Generate HTML or XML?

Several build servers require that you display reports in their interface by processing XML files with XSLT. For that reason, many of NCover’s reports are available in both HTML and XML formats. For most scenarios, though, you’ll want to generate HTML reports.

Questions? Comments?

Contact us.