IntelliJ IDEA 2022.2 Help

Read the coverage report

Code coverage results are displayed in the Coverage tool window, in the Project tool window, and in the editor after you run at least one configuration with coverage.

Code coverage results

Results of the code coverage analysis are saved to the coverage folder in the IDE system directory.

Coverage in the Project tool window

The Project tool window displays the percentage of the covered classes and lines for directories and the percentage of the covered methods and lines for classes.

Code coverage results in the Project tool window

Coverage in the Coverage tool window

The Code Coverage tool windows appears right after you run a configuration with coverage and displays the coverage report. If you want to reopen the Coverage tool window, select Run | Show Code Coverage Data from the main menu, or press Ctrl+Alt+F6.

The report shows the percentage of the code that has been executed or covered by tests. You can see the coverage result for classes, methods, and lines.

Branch coverage shows the percentage of the executed branches in the source code (normally, these are the if/else and switch statements). This information is available for the JaCoCo runner and for the IntelliJ IDEA runner with the Tracing option enabled.

Coverage results in the Coverage tool window

Code Coverage tool window options

Item

Description

the Up button

Go up one level.

the Flatten Packages button

Show all packages on the same level.

the Navigate with Single Click button

If this option is on, IntelliJ IDEA automatically opens the selected item in the editor. Otherwise, you need to double-click items to open them.

the Always Select Opened Element button

If this option is on, IntelliJ IDEA automatically locates in the tool window the files that you open in the editor.

the Generate report button

Generate a code coverage report and save it to the specified directory. Refer to section Save coverage data to a file for details.

Coverage results in the editor

In the editor, lines of code are highlighted with regard to their code coverage status in the gutter:

  • Green: lines that have been executed during simulation

  • Red: lines that haven't been executed during simulation

  • Yellow: lines covered with conditions tracing mode

To find out how many times a line has been run, click the color indicator in the gutter. A popup that opens shows the statistic for the line at caret. For the lines with conditions, the popup also provides statistics.

Coverage results shown in the editor

For JUnit tests, you can open the test that covers a line in a separate dialog. To do so, click the the Show Tests Covering Line icon in the popup. To be able to use this feature, enable the Tracing mode and Track per test coverage options for the current run/debug configuration in the Code Coverage area. For more information, refer to Set coverage in run configurations.

Click the Show Bytecode button to open the bytecode of the current class in a separate dialog, or the Edit Coverage Colors button to change the colors of the coverage indicators in the gutter.

Last modified: 29 November 2022