# JaCoCo coverage per test: which test covers this line in Java > JaCoCo has no coverage per test. Find which JUnit test covers a line: one run per test (delete jacoco.exec first), IntelliJ's per-test coverage, or Supercov. Web page: https://supercov.com/blog/jacoco-coverage-per-test · Published 2026-12-05 All Supercov pages for agents: https://supercov.com/llms.txt · Full text: https://supercov.com/llms-full.txt JaCoCo, IntelliJ IDEA and Supercov on the same Maven project, and why the one-run-per-test loop gave a wrong answer. JaCoCo cannot tell you which test covers a line. Its `jacoco.exec` records which lines ran during the whole JVM session, not which test ran them. IntelliJ IDEA can, in the editor, when tests run from a JUnit or TestNG run configuration with its own coverage runner, but not from a Maven or Gradle build. In a build, the only JaCoCo answer is one run per test, and that loop gives wrong answers unless you delete `jacoco.exec` between runs. ![A diagram of three tools. JaCoCo's mvn test writes jacoco.exec with hits per line, so line 11 is covered with no test named. IntelliJ IDEA's JUnit run configuration stores tests per line, in the IDE only. supercov -- mvn test stores tests per line and names the 2 tests that ran line 11.](https://supercov.com/assets/jacoco-coverage-per-test-flow-1360.674a9375b7.webp) *What a JaCoCo run stores, and whether it can name the tests.* Supercov, which we make, records coverage per JUnit test in one normal `mvn test` or `gradle test`, and `supercov runs latest line ` lists the tests that ran a line. [See below](#supercov-one-maven-run). ## At a glance | Tool | Per test? | How | | --- | --- | --- | | JaCoCo | No | One `mvn test -Dtest=Class#method` per test, deleting `target/jacoco.exec` before each | | IntelliJ IDEA | Yes, in the IDE | Settings, Coverage: IntelliJ IDEA runner, Track per test coverage; then Show Tests Covering Line in the gutter | | Supercov | Yes | `npx supercov -- mvn test`, then `npx supercov runs latest line ` | We measured on a small Maven project: a `Discount.apply` method, three tests for it and one checkout test that calls it, with JaCoCo 0.8.16, Maven 3.9.16 and JUnit 5.13.4 on JDK 26. Line 9, `return cents - 1000;`, runs in one test. Line 11, `return cents;`, runs in two. ![A grid of four methods against four tests, half, tenoff at least 10, tenoff under 10 and checkout, for line 9. The JaCoCo report names none. One run per test with jacoco.exec appended names three, wrongly. One run per test with jacoco.exec deleted names tenoff at least 10, in 4 runs. supercov runs latest line names the same test in 1 run.](https://supercov.com/assets/jacoco-coverage-per-test-grid-1360.153d3b0236.webp) *Which tests each method named for line 9 of Discount.java.* ## JaCoCo: one run per test, and delete jacoco.exec The JaCoCo report marks line 11 green, fully covered, with no tests named. Its Sessions page lists JVM sessions, not tests. JaCoCo's maintainer [put it plainly](https://groups.google.com/g/jacoco/c/CY4eWeoVoT4/m/dGKpxMLfDgAJ): "JaCoCo does not support this out of the box". His recipe is to write a JUnit listener that dumps and resets the execution data after every test, analyse each dump, and combine them. To find the tests by hand, run each test alone and read the report after it: ```sh rm -f target/jacoco.exec mvn test -Dtest='DiscountTest#tenoffDoesNothingUnderTen' ``` Leave out the `rm` and the answer is wrong. The agent's `append` option is `true` by default, so each run adds to the last one's data. In our loop the third test, `tenoffDoesNothingUnderTen`, was reported as running line 9, which it never reaches: line 9 had run in the test before it. With the file deleted each time, every test got its own correct answer. The cost grows with the suite: four tests took 4.8 s this way against 1.3 s for one run of all four. A suite of 2,000 tests means 2,000 Maven runs. ## IntelliJ IDEA: in the editor only IntelliJ's own coverage runner can track per-test coverage. [Its documentation](https://www.jetbrains.com/help/idea/code-coverage.html#track_coverage_per_test) lists the conditions: the IntelliJ IDEA runner, not JaCoCo; Track per test coverage selected; tests run through a JUnit or TestNG run configuration. Then click a covered line's gutter and choose Show Tests Covering Line. That answers it for one developer in the editor. It does not run in CI, and a build's `mvn test` or `gradle test` does not produce it. ## Supercov: one Maven run ```sh npx supercov -- mvn test npx supercov runs latest line src/main/java/shop/Discount.java:11 ``` ```text src/main/java/shop/Discount.java:11 Source 11 | return cents; Status COVERED Evidence: execution only Covering tests shop.CheckoutTest#checkoutAddsUpTheItems() [.::shop.CheckoutTest#checkoutAddsUpTheItems()] — unit/junit-platform shop.DiscountTest#tenoffDoesNothingUnderTen() [.::shop.DiscountTest#tenoffDoesNothingUnderTen()] — unit/junit-platform ``` Line 9 named only `tenoffTakesTenOffOrdersOfTenOrMore`. The run took 1.8 s, the same Maven build with Supercov's agent added. Use `gradle test` or `./gradlew test` after `--` for Gradle; JUnit 5, JUnit 4 through Vintage, and Kotlin tests on JDK 17 or newer are supported. Add `--json`, or several lines at once, for a script or a coding agent. To keep JaCoCo's reports for SonarQube or a coverage gate, keep it: Supercov does not replace the plugin in your build. See [JaCoCo vs SonarQube](https://supercov.com/compare/jacoco-vs-sonarqube.md) and [Java code coverage tools](https://supercov.com/compare/java-code-coverage.md). For the same question in Vitest, Jest and pytest, see [which test covers this line](https://supercov.com/blog/which-test-covers-this-line.md).