10

I know that in idea I can choose coverage runner on Run/Debug configuration like this:

enter image description here

but then I select class in tree I see the following menu:

enter image description here

And I cannot configure coverage runner here.

Is it possible to configure coverage runner tool to use by default?

Community
  • 1
  • 1
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

2 Answers2

8

In Run Configurations, at the bottom of the left side, there is a Defaults section. In there, you can set the default coverage runner for each type of run. It looks like you're using JUnit above, so select JUnit, then the Code Coverage tab. Choose your coverage runner. Each new run configuration will now use that coverage runner. Pre-existing run configurations won't be changed.

Crunch
  • 500
  • 3
  • 9
  • 1
    In IntelliJ IDEA 2016.2 (Build #IU-162.1121.32) this drop down is disabled for some reason. ChiefTwoPencils's answer above worked for me. – haggisandchips Sep 09 '16 at 08:28
  • 5
    In IntelliJ 2018.3.1 the default configuration is called a "template". Taking JUnit the path is Edit Configurations => Templates => JUnit => Code Coverage. Here you can select the default runner for all futures JUnit configurations. This is way easier then directly editing an internal IntelliJ file. – Mark Jan 04 '19 at 10:28
3

Yes, there's a way to change the default setting via the workspace.xml file in your .idea folder.

If you start to scroll down in that file you'll eventually come to a number of <configuration> tags. For example, the default values for the Application run configuration type on my machine is:

<configuration default="true" type="Application" factoryName="Application">
  <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
  <option name="MAIN_CLASS_NAME" />
  <option name="VM_PARAMETERS" />
  <option name="PROGRAM_PARAMETERS" />
  <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
  <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
  <option name="ALTERNATIVE_JRE_PATH" />
  <option name="ENABLE_SWING_INSPECTOR" value="false" />
  <option name="ENV_VARIABLES" />
  <option name="PASS_PARENT_ENVS" value="true" />
  <module name="" />
  <envs />
  <method />
</configuration>

Notice the runner attribute; to change the default runner to JaCoCo, change it to runner="jacoco". It won't change the runner on any existing ones automatically; only new run configurations will reflect the change. But you can change them manually just the same; they are more towards the bottom of the run configurations.

ChiefTwoPencils
  • 13,548
  • 8
  • 49
  • 75