Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58184

Jacoco delta threshold failures if coverage *increases* over threshold

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • jacoco-plugin
    • 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.

       

            pulgupta Pulkit Gupta
            rainoko Raino Kolk
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: