Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Idea How to show tests covering line

I'm using IDEA in order to analyze our code coverage. I can see that some lines were called N number of times. But I also want to know which test caused that line call. I see the appropriate button "Show tests covering line", but this button is disabled for all of the lines.

So what is the reason of that behavior and is it possible to force IDEA to show tests which called a particular line of the code

enter image description here

like image 638
Arseny Istlentyev Avatar asked Oct 27 '17 10:10

Arseny Istlentyev


People also ask

Why test 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.

How do you show test coverage?

You simply take: (A) the total lines of code in the piece of software you are testing, and. (B) the number of lines of code all test cases currently execute, and. Find (B divided by A) multiplied by 100 – this will be your test coverage %.

How do I highlight code coverage in IntelliJ?

To enable code coverage highlighting In the IDEA IDE, on the Analyze menu, click Show Code Coverage Data, or use the Ctrl+Alt+F6 keyboard shortcut.


1 Answers

From the docs:

This button is only available in the Tracing mode, and with the Track per test coverage check box selected

You can enable tracing and 'track test per coverage' in the Run/Debug window. Here's a screenshot:

enter image description here

More details in the docs.

like image 51
glytching Avatar answered Sep 21 '22 15:09

glytching