IntelliJ IDEA 2019.2 Help

Configuring code coverage measurement

IntelliJ IDEA makes it possible to configure the various aspects of code coverage measurement. In this section:

Configuring the way coverage suites are processed

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), click Coverage under Build, Execution, Deployment.

  2. Define how the collected coverage data will be processed:

    • To have the Code Coverage dialog shown every time you launch a new run configuration with code coverage, choose Show options before applying coverage to the editor.

    • To discard the new code coverage results, choose Do not apply collected coverage.

    • To discard the active suites and use the new one every time you launch a new run configuration with code coverage, choose Replace active suites with the new one.

    • To have the new code coverage suite appended to the active suites every time you launch a new run configuration with code coverage, choose Add to the active suites.

  3. Define the behaviour of the Coverage tool window when an application or test is run with coverage:

    • To have the Coverage tool window opened automatically, select the Activate Coverage View checkbox.

    • To open the Coverage tool window manually, clear the Activate Coverage View checkbox.

Configuring code coverage measurement options

  1. Open the Edit Run/Debug Configuration dialog, add the desired run/debug configuration, and click the Code Coverage tab.

  2. In the Code Coverage tab, define the following options:

    • From the Choose coverage runner list, select the desired code coverage runner. The available options are:

      • EMMA
      • IntelliJ IDEA

    • Choose the options for the selected runner:

      • For the EMMA runner, only the Sampling mode is available.

      • For the IntelliJ IDEA runner, you can choose between the Sampling or Tracing modes.

    • Specify the scope to measure code coverage for. Do one of the following:

      • To specify a class, click the Add Class button.

      • To specify a package, click the Add Package button.

    • To have code coverage statistic collected for folders with tests as well, select the Enable Coverage in Test Folders checkbox.

Changing colors of the coverage highlighting

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Editor | Color Scheme | General.

  2. In the list of components, expand the Line Coverage node and select a type of coverage: for example, Full, Partial or Uncovered. Click the Foreground field to open the Select Color dialog. Select a color and click Apply.

    Configure code coverage colors

Last modified: 17 October 2019