JaCoCo Coverage Below Threshold in CI - Fix the Check Failure
The JaCoCo coverage check fails the build when measured coverage drops under a configured minimum. It is a deliberate quality gate, not a flake - a retry produces the identical percentage until tests or rules change.
What this error means
The verify/check phase fails with Rule violated for bundle app: lines covered ratio is 0.62, but expected minimum is 0.80. Coverage fell below the threshold after new code or removed tests.
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.12:check (default-check)
on project app: Coverage checks have not been met. See log for details.
[INFO] Rule violated for bundle app: lines covered ratio is 0.62, but expected minimum is 0.80Common causes
New untested code lowered coverage
Added classes/branches without tests pull the ratio below the configured floor, and the check enforces it.
Coverage data missing or mis-scoped
A broken @{argLine} (no agent attached), or generated code not excluded, makes coverage look artificially low and trips the rule.
How to fix it
Add tests or exclude generated code correctly
Cover the new paths, and exclude generated/DTO classes from the rule so the metric reflects real code.
<configuration>
<excludes>
<exclude>**/generated/**</exclude>
<exclude>**/*MapperImpl.*</exclude>
</excludes>
<rules>
<rule><limits><limit><counter>LINE</counter><value>COVEREDRATIO</value>
<minimum>0.80</minimum></limit></limits></rule>
</rules>
</configuration>Verify the agent actually recorded coverage
- Confirm Surefire keeps
@{argLine}so the JaCoCo agent attaches (otherwise coverage reads 0%). - Check the report shows real numbers before tuning the threshold.
- Adjust the
<minimum>only as a deliberate policy decision, not to mask missing tests.
How to prevent it
- Keep the JaCoCo agent attached via
@{argLine}, exclude generated code, and write tests for new branches so the gate reflects genuine coverage.