Backend Development 10 min read

Super-Jacoco: A One‑Stop Java Code Coverage Platform for Full and Differential Coverage

Super‑Jacoco is an open‑source, one‑stop Java coverage platform that extends JaCoCo with Git diff analysis to provide low‑overhead, non‑intrusive full‑run and incremental (diff) coverage for unit, functional, and environment tests, offering distributed scalability and HTML visual reports for easy insight.

Didi Tech
Didi Tech
Didi Tech
Super-Jacoco: A One‑Stop Java Code Coverage Platform for Full and Differential Coverage

Super‑Jacoco is a one‑stop platform built on top of JaCoCo and Git to collect Java code coverage data both for full runs and for diff (incremental) runs. It aims to provide low‑cost, non‑intrusive coverage collection for unit tests, functional tests, and environment‑level testing.

Background and Motivation

In software delivery, test quality depends heavily on comprehensive test case design. Common problems include:

Developers write many unit tests but repeatedly execute the same code paths, leaving edge cases uncovered.

Test cases still miss exceptional scenarios after multiple reviews.

Automated regression tests cannot guarantee coverage of all code logic.

To address these issues, a tool that can collect coverage for changed code (diff coverage) is needed. Existing tools such as JaCoCo and EMMA only support full‑run coverage.

Super‑Jacoco Overview

Super‑Jacoco extends JaCoCo with Git diff analysis to collect coverage for newly added or modified methods. It works in an on‑the‑fly mode, requiring no code instrumentation. Features include:

Support for both unit‑test and functional‑test coverage.

Full‑run and diff‑run collection.

Zero‑intrusion on the source code.

Distributed architecture for high availability.

HTML visual reports for easy analysis.

Architecture & Core Principle

The platform performs two main steps to achieve incremental coverage:

Obtain the diff between a base branch (e.g., master ) and a feature branch using JGit.

Modify JaCoCo’s ClassProbesAdapter.visitMethod to instrument only the methods identified in the diff.

These modifications enable JaCoCo to generate coverage data limited to the changed methods while still supporting full‑run collection when no diff file is provided.

Usage Workflow

1. Installation : Install MySQL, create the database, and run the provided sql/db.sql script.

2. Build : Install JDK 1.8 and Maven, clone the repository, adjust application.properties for DB and GitLab settings, then run mvn package -Dmaven.test.skip=true to produce super-jacoco.jar .

3. Deploy : Start the service with nohup java -jar super-jacoco.jar & (default port 8899).

4. Coverage Collection APIs :

1) Start unit‑test coverage collection
URL: /cov/triggerUnitCover
Method: POST
Body: {"uuid":"uuid","type":1,"gitUrl":"git@git","subModule":"","baseVersion":"master","nowVersion":"feature","envType":"-Ptest"}
Response: {"code":200,"data":true,"msg":"msg"}
2) Retrieve unit‑test coverage result
URL: /cov/getUnitCoverResult
Method: GET
Param: uuid
Response: {"code":200,"data":{"coverStatus":1,"lineCoverage":100.0,"branchCoverage":100.0,"reportUrl":"http://..."},"msg":"msg"}
3) Start environment coverage collection
URL: /cov/triggerEnvCov
Method: POST
Body: {"uuid":"uuid","type":1,"gitUrl":"git@git","baseVersion":"master","nowVersion":"feature","address":"127.0.0.1","port":"8088"}
Response: {"code":200,"data":true,"msg":"msg"}
4) Retrieve environment coverage result
URL: /cov/getEnvCoverResult
Method: GET
Param: uuid
Response: same format as unit‑test result

Key Benefits

General: works for both unit and manual testing, full and diff coverage.

Non‑intrusive: on‑the‑fly instrumentation without code changes.

High availability: distributed task nodes can scale horizontally.

Visualization: HTML reports provide clear coverage insight.

Conclusion

In fast‑moving development environments, precise testing is essential, and code coverage is a core metric. Super‑Jacoco delivers an easy‑to‑use, low‑overhead solution for both full and incremental coverage, facilitating accurate testing practices. The project is open‑source and welcomes contributions.

GitHub repository: https://github.com/didi/super-jacoco

JavaCode Coverageci/cdTestingopen-sourceDiff CoverageJaCoCo
Didi Tech
Written by

Didi Tech

Official Didi technology account

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.