Overview

C/C++test CT can generate code coverage reports in various formats. Reports are generated based on coverage data files produced with the cpptestcov compute command, which is an obligatory step in the report generation process. See the example below: 

cpptestcov compute -map=.cpptest/cpptestcc -clog=cpptest_results.clog -out=cov-data

Once coverage data files are available, reports can be generated with the following command: 

cpptestcov report <report format> <options> <coverage data files directory> 

For example:  

cpptestcov report text -coverage LC cov-data

Report generation process does not modify the coverage date files. You can generate multiple reports from the same coverage data files.  

C/C++test CT supports the following reporting formats:

FormatDescription
coberturaCobertura format, may be useful for integrations with external tools
dtpPublish coverage and test results to DTP. Published reports are visible in the Parasoft DTP 
htmlCoverage report in HTML format; see also Coverage Report with Code Annotations.
jsonCoverage statistics in json format
lcovLine Coverage report in lcov format, useful for integrations with external tools 
markdownCoverage statistics in Markdown format
mcdcText report with MCDC tables
suppressed-linesText report with suppressed lines coverage information
suppressionsText report with suppressed coverage elements
textCoverage statistics in plain text format
uncovered-linesText report with uncovered lines

See Command Line Reference for cpptestcov for more details regarding reporting options syntax.

Coverage Report with Code Annotations

Generating HTML Reports

C/C++test CT provides advanced HTML reporting with source code annotations for complete insight into the coverage results. To generate an HTML report with code annotations, use the cpptestcov report html command with the -code option. To include multiple coverage metrics, use the -coverage option and specify the desired set of metrics.

Example:  
The HTML report will include source code annotations for the Line Coverage, Decision Coverage and MCDC metrics. It will be generated based on the coverage data files from the cov-data folder, and the main report file will be report/coverage.html

cpptestcov report html -code -coverage LC,DC,MCDC -out report/coverage.html cov-data

Run cpptestcov report html --help to view a complete list of options.

Report Structure

The generated HTML report has a nested (drill-down) structure with the following levels:

  • Use the navigation buttons to move between levels.
  • Click on the table header to sort the coverage statistics table.

By default, the full (absolute) path to tested source file will be presented on the report. To remove the host-specific part of the path, use the -root option and specify the root location of the project, when generating the report.  

Example:  
The source file project/main.cpp will be displayed instead of the full path /home/user/dev/project/main.cpp:

-root /home/user/dev/project

Code Annotations

HTML coverage reports should be generated with the -code option.

To access source code annotations, drill down to the file-level report. This report includes the source code for the selected file, with additional coverage-related annotations for each coverable line of the source code:

Each type of coverage annotations can improve understanding of the coverage results. They can be used individually or combined, depending on the use case and preference.

Coverage Status Indicator

The coverage status indicator allows you to quickly find code locations with missing (or incomplete) coverage. It is a cumulative indicator for all coverage metrics included in the report, regardless of the currently selected metrics.

The following color code is used:

Coverage Highlights for Selected Metrics

The coverage highlights shows coverage elements directly in the source code. Only currently selected coverage metrics are visualized (see "coverage selectors").

The following color code is used:

When multiple coverage metrics are selected, the code highlights may overlap. The not-covered (red) or partially-covered (yellow) highlights will always overlap the fully covered elements (green).

Use the coverage selector to visualize code highlights for a specific coverage metric only.

Coverage Details for Selected Metrics

The left bar shows coverage details for the currently selected metrics, with each metric displayed in its own column. It uses the same color code as the coverage highlights:

In addition to the color code, the left bar uses symbolic indicators ([+][-]) to visualize details about coverage elements, making it easier understand possible gaps in the code coverage results.

Coverage metric

Coverage details indicators

Line Coverage

[+] line was covered

[-] line was not covered

Statement Coverage

[+] statement was covered

[-] statement was not covered

Block Coverage

[+] block was covered

[-] block was not covered

Decision Coverage

[+] branch was taken

[-] branch was not taken

Each branch of a decision has its own indicator, for example: [+-+] – the first branch was taken, the second branch was not taken, and the third branch was taken. Overall, the decision was partially covered.

MCDC

[+] condition was covered

[-] condition was not covered

Each condition of a decision has its own indicator, for example: [+-+]  the first condition was covered, the second condition was not covered, and the third condition was covered. Overall, the decision was partially covered in terms of the MCDC metric.

Simple Condition Coverage

[+] value was taken

[-] value was not taken

Each condition is presented as a [true,false] pair, for example: [+-] the value of true was taken, and the value of false was not taken. Overall, the condition was partially covered.

Function Coverage

[+] function was called

[-] function was not called

Call Coverage

[+] call was executed

[-] call was not executed

If there are multiple coverage elements of given type in the same line (e.g. multiple statements), each element will be presented separately, for example:

Coverage metric

Multiple coverage details indicators in the same line

Statement Coverage

[+][+][-] the first and the second statement in the line were covered, and the third statement was not covered.

Simple Condition Coverage

[+-][++] the first condition in the line was partially covered (the true value was taken, and the false value was not taken), the second condition in the line was fully covered (both true and false values were taken).

Expandable Coverage Details for Simple Condition, Decision and MCDC Metrics

Additional coverage details for the elements of Simple Condition Coverage, Decision Coverage and MCDC type are available as expandable in-line comments. You can either view the details for an individual line or expand (or collapse) all lines with details at once.

This section is especially useful when working with the MCDC metric. The expandable coverage details provide insight into which condition values were tested, as well as which condition values are missing to achieve 100% of MCDC for a given decision. It also provides information which pairs of input vectors were considered when computing the MCDC values for each condition of a decision.