How to Activate Branch Coverage in IntelliJ

IntelliJ is the Java IDE from JetBrains. I used it a few times over the last months for online workshops like “Make Your Code More Testable” or the 99 minutes series of Ministry of Testing.

As with the other IDEs from JetBrains, you get nearly everything you need right out of the box. Test coverage is no exception and it works without any effort on your side. However, the nice feature of branch coverage is well hidden and impossible to discover.

Next to the start / run buttons is a drop-down list with your run configurations. Select “Edit Configurations…“:

Edit Configurations should be the first entry

Select the run / debug configuration you want to run with branch coverage. At the right end of the dialog is a link for “Modify options“:

Look at the right top corner

You can expand the menu and inside Code Coverage is an entry for Coverage settings. It opens up and shows another list from which you need to activate the option “Use tracing“:

Select Use Tracing

Do not forget to save the configuration. From now on branch coverage is included when you run this configuration with code coverage.

There may be some reasonable explanation while branch coverage is turned on with the option “Use tracing” but I have now clue what that could be. It works and I hope it saves you the time to figure it out by yourself.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.