SupercovCompare
← All comparisons

Java · Comparison

JaCoCo vs Cobertura

Use JaCoCo. Cobertura's last release is from 2015 and its Maven plugin fails on a current JDK. What each measures, and how to move a Maven build across.

JaCoCo or Cobertura?

Use JaCoCo. Cobertura’s last release, 2.1.1, is from February 2015, and its Maven plugin does not run on a current JDK. JaCoCo is maintained: 0.8.15, from June 2026, supports Java 26. The name Cobertura lives on mostly as an XML report format that CI tools read.

What happens when you run each

The same Maven project, one class and two JUnit tests, on JDK 26:

mvn test

With jacoco-maven-plugin 0.8.15 this wrote a report: 8/8 instructions, 3/4 branches, 3/3 lines.

mvn cobertura:cobertura

With cobertura-maven-plugin 2.7, the latest, the build failed before any class was instrumented:

Could not find artifact com.sun:tools:jar

The plugin depends on tools.jar, which the JDK stopped shipping in Java 9.

How they differ

JaCoCoCobertura
Latest release0.8.15, June 20262.1.1, February 2015
How it measuresA Java agent instruments classes as they loadRewrites compiled classes before the tests run
What it countsInstructions, branches, lines, methods, classesLines and branches
Build toolsMaven, Gradle’s built-in jacoco plugin, Ant, command lineMaven and Ant

JaCoCo’s counters come from bytecode, so it needs no source changes and works for Kotlin and other JVM languages too.

Moving from Cobertura to JaCoCo

Replace the plugin in your pom.xml:

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.15</version>
  <executions>
    <execution>
      <goals><goal>prepare-agent</goal></goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>test</phase>
      <goals><goal>report</goal></goals>
    </execution>
  </executions>
</plugin>

The report lands in target/site/jacoco, as HTML, XML and CSV. Expect the percentages to change: the tools count lines and branches differently, so set new thresholds instead of carrying the old ones over.

If a CI step still expects Cobertura XML, check whether it reads JaCoCo XML too. GitLab’s coverage view and Codecov read both. See lcov vs Cobertura for the format.

What Supercov adds

npx supercov -- mvn test
npx supercov runs latest gaps

JaCoCo reports a whole run. Supercov runs the same Maven or Gradle command and records coverage per test, with MC/DC and assertion coverage. On the project above it reported 3/3 lines, 4/4 branches and 1/2 MC/DC conditions: no test tried a signed-in session that had expired. It can also write Cobertura XML with npx supercov runs report --format cobertura.

For a wider comparison, see Java coverage: JaCoCo, OpenClover, and Supercov.

Example evidence: fixture source, commands and recorded results (JSON). Measured October 12, 2026 with Supercov 4.3.0. These small examples are not a performance benchmark or a general conformance test.