-
Bug
-
Resolution: Fixed
-
Minor
-
None
Jacoco delta threshold got failure if some coverage metrics decreases less than delta threshold but some increases over delta threshold.
Problematic code is
JacocoPublisher.java
public Result checkBuildOverBuildResult(Run<?,?> run, PrintStream logger){ JacocoDeltaCoverageResultSummary deltaCoverageResultSummary = JacocoDeltaCoverageResultSummary.build(run); logger.println("[JaCoCo plugin] Delta coverage: class: " + deltaCoverageResultSummary.getClassCoverage() + ", method: " + deltaCoverageResultSummary.getMethodCoverage() + ", line: " + deltaCoverageResultSummary.getLineCoverage() + ", branch: " + deltaCoverageResultSummary.getBranchCoverage() + ", instruction: " + deltaCoverageResultSummary.getInstructionCoverage() + ", complexity: " + deltaCoverageResultSummary.getComplexityCoverage()); if(Math.abs(deltaCoverageResultSummary.getInstructionCoverage()) <= deltaHealthReport.getDeltaInstruction() && Math.abs(deltaCoverageResultSummary.getBranchCoverage()) <= deltaHealthReport.getDeltaBranch() && Math.abs(deltaCoverageResultSummary.getComplexityCoverage()) <= deltaHealthReport.getDeltaComplexity() && Math.abs(deltaCoverageResultSummary.getLineCoverage()) <= deltaHealthReport.getDeltaLine() && Math.abs(deltaCoverageResultSummary.getMethodCoverage()) <= deltaHealthReport.getDeltaMethod() && Math.abs(deltaCoverageResultSummary.getClassCoverage()) <= deltaHealthReport.getDeltaClass()) return Result.SUCCESS; else if(deltaCoverageResultSummary.isCoverageBetterThanPrevious()) return Result.SUCCESS; else return Result.FAILURE; }
The above code uses abs. This means that check not make any difference of increase or decrease. If not all metrics are increased then isCoverageBetterThanPrevious gives false. so Despite all decreases are below delta threshold build fails if some of increase more than delta. This is not logical because coverage increase should not be measured against delta at all.