Search code examples
unit-testingintellij-ideacode-coverage

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


Solution

  • From the docs:

    For JUnit tests, you can open the test that covers a line in a separate dialog. To do so, click the the Show Tests Covering Line icon in the popup. To be able to use this feature, enable the Tracing mode and Track per test coverage options for the current run/debug configuration in the Code Coverage area. For more information, refer to Set coverage in run configurations.

    The Set Coverage in run configurations page details how to do this for your IDE version. Newer versions will have a Coverage Tab, older versions will not. The set up instructions for both are detailed in this page.