JaCoCo

jacoco.org ↗

A Java code-coverage library that records which instructions, lines, and branches run during tests.

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Not confirmed
Sign-up required
Not confirmed

Ask SI about JaCoCo

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the JaCoCo homepage

What it does

JaCoCo is a Java code-coverage tool that instruments code while tests execute, saves execution data, and builds reports. Its documentation covers Maven and Ant integrations, a Java agent, and command-line use. Teams add it to an existing test workflow to see which parts of the application tests reached and, optionally, set coverage thresholds in a build. JaCoCo reports execution coverage; the project still needs test cases and assertions that establish correct behavior.

A coverage report helps answer a narrower question than a test result: which parts of the Java code ran during the test suite? JaCoCo collects execution data with a Java agent and turns it into HTML, XML, or other reports. Its Maven plug-in can attach the agent to test execution and create a report for unit or integration tests. A team can add the plug-in to an existing Maven build, run its normal test phase, and inspect the report for code that was not reached.

Check the runner configuration

JaCoCo's Maven guide documents an important integration constraint: tests must run with the JaCoCo agent enabled. In particular, the Surefire or Failsafe configuration must not set forkCount to zero or forkMode to never, because then the agent will not record coverage. The Maven integration requires Maven 3.0 or newer and Java 1.8 or newer for the Maven runtime, according to the current guide.

Coverage thresholds can be configured for counters such as instructions, lines, and branches. That makes JaCoCo useful as one signal in a Java testing workflow, but a high percentage alone does not show that a test checks meaningful outcomes. JaCoCo is distributed under the Eclipse Public License 2.0, and no hosted account or paid plan is part of the documented Maven workflow.

Strengths

  • Collects Java execution coverage and produces reports that can be integrated into Maven builds.
  • Supports instruction, line, branch, complexity, method, and class coverage counters.
  • Can set build rules for coverage ratios or missed-code limits.

Watch out for

  • JaCoCo measures code execution but does not define test cases or prove that assertions check the right behavior.
  • The Java agent will not collect coverage when Maven Surefire or Failsafe disables test-process forking as described in the documentation.

Best for

  • Java teams locating untested lines or branches in an existing test suite
  • Maven projects that want coverage reports as part of local or CI builds
  • Maintainers setting coverage thresholds for Java modules

Sources