JaCoCo coverage per test: which test covers this line in Java
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.

Supercov, which we make, records coverage per JUnit test in one normal mvn test or gradle test, and supercov runs latest line <file:line> lists the
tests that ran a line. See below.
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 <file: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.

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: “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:
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 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
npx supercov -- mvn test
npx supercov runs latest line src/main/java/shop/Discount.java:11src/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 and Java code coverage tools. For the same question in Vitest, Jest and pytest, see which test covers this line.
More coverage guides
- Ruby && and || coverage: what SimpleCov's branch coverage misses
- Playwright code coverage of your server: Express, measured
- Code coverage for AI coding agents: what the agent reads
- Which test covers this line? Vitest, Jest and pytest
- Jest coverageThreshold: global, per-folder and per-file
- JaCoCo aggregate report for multi-module Maven and Gradle builds
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Merge coverage reports from shards: Vitest, Jest and coverage.py
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- Kover exclude: classes, packages and generated code
- sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
- istanbul ignore next vs c8 ignore next: every hint, measured
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code