This topic explains how to collect coverage information for JUnit tests executed in IntelliJ IDEA.
Jtest can collect coverage information for JUnit tests when a run configuration is executed in IntelliJ IDEA. To enable collecting coverage with Jtest, you can do one of the following:
1 Configuring the Jtest coverage runner for Gradle run configurations is supported for IntelliJ 2019.3 and later.
To customize the Jtest run configuration, open the Startup/Connection tab of your run JUnit configuration and select Jtest.
The following options are available:
When you run your tests with a run configuration created on the base of IntelliJ's template run configuration, you can configure your run configuration to collect coverage with the Jtest coverage runner.
When the test configuration is run, coverage is collected with the Jtest coverage runner and displayed in the Jtest Coverage view (see Viewing Coverage for details).
Customizing IntelliJ's JUnit or Gradle run configuration templates (in some IntelliJ version known as "defaults") allows you to configure collecting coverage with Jtest coverage runner for all JUnit or Gradle run configurations you create. Go to Run> Edit Configurations..., choose the JUnit or Gradle temple, open the Code Coverage tab, and select the Jtest coverage runner from the drop-down menu.
By default, IntelliJ narrows down the coverage scope to the packages you selected. For this reason, if you execute a test suite, coverage is only collected for tests that are in the same package as the test suite. To ensure that coverage is collected for all tests listed in a test suite, you may need to clear the list of includes automatically generated by IntelliJ in the run configuration.