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.

Working with Workbench reports

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:

Procedure

Working with HTML reports

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.

Procedure

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

HTML report
Use the breadcrumbs to navigate back to a higher level report. For example, in this example, click Overall Summary from the 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

Open the source code and view its code coverage results in the editor.

Procedure

Open the source code and view its code coverage results in the editor. In 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.

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 below. Note: this capability is not supported within HTML reports.

editor highlight

Navigating to covered or uncovered code in the source

Procedure

  • To navigate to the next line in the source code having a specified coverage level use 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

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.

About this task

Procedure

  • To turn the code coverage indicators off, right-click on the ruler column of the editor and uncheck the Show Line Coverage option.
  • To turn on the code coverage indicators again, check the Show Line Coverage option.

Feedback