Press the keys to navigate to the next or previous product.
JaCoCo Java Code Coverage Library

JaCoCo Java Code Coverage Library

Free code coverage library for Java

JaCoCo is the premier open‑source Java code coverage library, created by the EclEmma team to deliver a lightweight, flexible, and standards‑compliant solution for measuring how thoroughly your tests exercise your code. JaCoCo seamlessly instruments Java bytecode on‑the‑fly, requiring no source files and enabling coverage analysis even in production or CI environment.

With built‑in support for multiple coverage counters (instructions, branches, lines, methods, types, and cyclomatic complexity), it provides deep insights into code quality and dead code detection.

Integrations with Maven, Ant, Gradle, IDEs (Eclipse/EclEmma), and CI tools like Jenkins and SonarQube make it an indispensable part of modern DevOps pipelines.

Key Features:

1. Comprehensive Coverage Metrics:

  • Instruction (C0) & Branch (C1) Coverage: Tracks the execution of individual bytecode instructions and decision branches for fine‑grained analysis.
  • Line, Method & Class Coverage: Reports which lines, methods, and classes are exercised, helping identify untested code areas.
  • Cyclomatic Complexity Analysis: Measures code complexity to spotlight overly intricate methods that may need refactoring.

2. Lightweight Java Agent Instrumentation:

  • On‑The‑Fly Bytecode Instrumentation: Injects probes into class files at load time via a standard Java agent, requiring no changes to source code or build scripts.
  • Framework‑Agnostic Deployment: Works transparently with plain Java applications, OSGi frameworks, web containers, and EJB servers.

3. Build & CI Tool Integrations:

  • Maven Plug‑in: Adds the JaCoCo runtime agent to your test suite and generates detailed HTML/XML reports with minimal configuration.
  • Ant Tasks & Gradle Support: Provides similar capabilities for Ant and Gradle builds, including source highlighting and line number inclusion when compiled with debug info.
  • CI/CD Friendly: Commonly embedded in Jenkins, GitLab CI, and SonarQube pipelines to ensure continuous coverage monitoring and quality gating.

4. Rich, Exportable Reports:

  • HTML & XML Outputs: Generates intuitive visual reports and machine‑readable XML for automation and dashboarding.
  • API & Custom Reporting: Offers a public API with examples (CoreTutorial, ExecDump, MBeanClient) to build bespoke tools or integrate with proprietary systems.

5. Broad Platform & Version Support:

  • Java Class Version Compatibility: Officially supports class files from Java 1.0 through 24, with experimental support for version 25, while requiring only JRE 1.5 at runtime.
  • External Library Coverage: The agent can measure coverage of third‑party libraries, frameworks, or even Java itself, aiding dead‑code removal and dependency analysis.

Benefits & Use Cases:

  • Improved Code Quality: By highlighting untested paths and complex code, JaCoCo empowers teams to write more robust, maintainable software.
  • Faster Feedback Loops: Real‑time instrumentation and report generation keep developers informed of coverage regressions immediately.
  • Data‑Driven Refactoring: Cyclomatic complexity metrics and fine‑grained coverage data guide efforts to simplify and optimize critical code paths.
  • Compliance & Standards: Meets enterprise requirements for quality gates, audit trails, and test coverage thresholds in regulated industries.

Incorporating JaCoCo into your Java projects guarantees transparent, accurate, and automated coverage analysis—fueling better tests, faster releases, and higher‑quality software.

Tags:

JavaUnit Testing
Previous Tool Next Tool