Viewing code coverage results

After you enable code coverage on a project, coverage statistics are generated the next time that the application is launched. You can view the code coverage results in the Package Explorer view or in the Java™ editor.

Code coverage indicators

Code coverage indicators show whether the code met acceptable code coverage levels and whether a line of code was covered, partially covered, or not covered at all.

Viewing code coverage results in the Package Explorer view

In the Package Explorer, indicators show whether the code meets the acceptable coverage levels that are configured for the project. The color of the elements listed under the project reflect the percentage of lines that are covered. You can change both the default colors and the acceptance levels, but these are the defaults:

  • Green indicates that 80% or more of the lines are covered.
  • Red indicates that less than 80% of the lines are covered.
    Code Coverage Indicators

Viewing code coverage reports in the Java editor

In the Java editor, indicators show which lines have been covered and which have not. By default, a green bar next to the line number indicates that the line was covered, a red bar that it was not covered, and a yellow bar that it was partially covered. You can hold your mouse over the indicator to see the coverage specifics, as shown here. This ability is particularly useful for partially covered lines because you see the percentage of the elements in the line that are covered.

Java Editor Indicators

Navigating to covered, partially covered, or uncovered code in the source

To navigate to the next line in the source code having a specified coverage level, in the drop down menu from the "Navigate to next item in a list" toolbar button, select the coverage criteria to be used for the navigation. For example, to navigate from uncovered line to uncovered line in the source code, select uncovered code:

Navigating covered lines
and then click on the "Navigate to next item in a list" toolbar button to go to the next uncovered line in the source code. If you select two or more types of code coverage in the drop down menu, clicking on the toolbar button will navigate to the next line in the source that satisfies any of the specified conditions.

Removing Code Coverage Indicators

You can remove the code coverage indicators from the Package Explorer, views, and Java editor, but code coverage is still enabled for the selected project until you disable it. Click Run > Code Coverage > Remove Indicators. You can remove indicators from all or selected projects.


Feedback