Viewing code coverage results

You can view your code coverage results in either a Workbench or an HTML report or within the editor. By default, Workbench reports are generated.

About this task

This task explains how you can view your code coverage data from within Workbench reports, HTML reports, or the editor.

Working with Workbench reports

About this task

Using the Workbench report, you can sort columns to help you quickly identify unacceptable levels of coverage. You can sort the code coverage data by element, coverage, covered lines, or total lines by:
  • Clicking on the column header within the report. Clicking on the header will toggle the sort order from ascending to descending order.
  • Using the Sort By pulldown Sort by pulldown.

    Workbench report

You can also use the element icon Element icon to filter the reported elements. The icon serves as a toggle and can be used to either show all report elements or only those that did not meet the acceptance criteria. Note that each failed element is decorated in the report with a red "x" overlay. For example, the following report filters the above report to show only those elements that did not pass the acceptance thresholds. Note that the code coverage results for payroll.cpp are no longer reported:

Workbench filtered report

Lastly, from the Workbench report you can open the source in the editor, either by double-clicking on the compilation unit (such as a source file or function) or right-clicking on the compilation unit and clicking Open in Editor.

Working with HTML reports

About this task

Using the HTML report, you can sort columns to help you quickly identify unacceptable levels of coverage. You can sort the code coverage data by covered lines, total lines, or % coverage. Clicking on the column header within the report will toggle the sort order from ascending to descending order.

To see the detailed code coverage results for a specific module, compilation unit, or source file, click on it. For example, clicking on the payroll.cpp source file in the following report displays its code coverage details:

HTML reportUse the breadcrumbs to navigate back to a higher level report. For example, click Overall Summary in this breadcrumb "breadcrumbs" to go back to the overall summary.

Note: Source cannot be opened in the editor from an HTML report. This capability is only supported from within a Workbench report.

Viewing code coverage reports in a remote editor

About this task

To open the source code and view its code coverage results in the editor, from within the Workbench code coverage report either double-click on the compilation unit (such as a source file or function) or right-click the compilation unit and click Open in Editor. (This capability is not supported within HTML reports.) The source will open in the editor with decorations showing the code coverage for each line. By default, a green bar next to the line indicates that the line was covered; a red bar that it was not covered. Hold your mouse over the indicator to see the coverage specifics, as shown here:

editor highlight

Navigating to covered or uncovered code in the source

About this task

Within the editor, you can navigate to the next line in the source code having a specified coverage level using the drop down menu of the Navigate to next item in a list toolbar button:

Uncovered Code

By default, both Covered Code and Uncovered Code are selected. (Note that Partially Covered Code is not supported for compiled language code coverage.)

To change the coverage criteria, check or uncheck the various items until you arrive at the desired list of criteria to be used for the navigation. For example, to navigate from uncovered line to uncovered line in the source code, select Uncovered Code as shown above. Click on the Navigate to next item in a list toolbar button to go to the next uncovered line in the source code.

Note that with both covered code and uncovered code selected, clicking on the toolbar button will navigate to the next line in the source that satisfies either of these specified conditions.

Turning code coverage decorations on and off in the source

About this task

By default, code coverage indicators are shown in the editor. You can remove the code coverage indicators from the editor, but code coverage is still enabled for the selected launch of the program. To turn the code coverage indicators off, right click on the ruler column of the editor and uncheck the Show Line Coverage option. You can also check the Show Line Coverage option at a later time to turn on the code coverage indicators again.


Feedback