Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage in IntelliJ

I see that the build-in code coverage in Intellij is pretty minimal (only include line coverage, and not branch coverage).

What are the recommended code coverage libraries to work with IntelliJ?

(I used to work with Jacoco in Eclipse).

like image 643
Paz Avatar asked Jan 23 '18 12:01

Paz


People also ask

How do I show code coverage in IntelliJ?

Coverage in the Coverage tool window 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.

Why code coverage is not showing in IntelliJ?

From the main menu, select Run | Show Coverage Data ( Ctrl+Alt+F6 ). In the Choose Coverage Suite to Display dialog, select the checkboxes next to the necessary suites, and click Show selected. IntelliJ IDEA opens the coverage results for the selected test suites.

What does coverage mean in IntelliJ?

Code coverage in IntelliJ IDEA allows you to see the extent to which your code has been executed. It also lets you verify the extent to which your code is covered by unit tests, so that you can estimate how effective these tests are.

How do you show code coverage?

Code coverage option is available under the Test menu when you run test methods using Test Explorer. The results table shows the percentage of the code executed in each assembly, class, and procedure. The source editor highlights the tested code.


1 Answers

The IntelliJ IDEA code coverage runner provides branch coverage.

Tracing mode enables accurate collection of the branch coverage, with the ability to track tests, view coverage statistic, and get additional information on each covered line.

(From the docs)

To engage this, open the Edit Run/Debug Configuration dialog box for your test run and click on the Code Coverage tab. Then ...

  • Chose coverage runner: IntelliJ IDEA
  • Click on Tracing (instead of the default: Sampling)

Run your test and then click into the class from the Coverage Window and you'll see branch information in the side bar.

Here's a screenshot:

enter image description here

like image 119
glytching Avatar answered Nov 15 '22 00:11

glytching