1

What is the significance of minimumClassCoverage and maximumClassCoverage in https://jenkins.io/doc/pipeline/steps/jacoco/

jacoco exclusionPattern: '**/generated-sources/**.class',
                            execPattern: '**/coverage-reports/jacoco-unit.exec',
                            inclusionPattern: '**/*.class',
                            sourceExclusionPattern: '**/generated-sources/**.java',
                            changeBuildStatus: true,
                            minimumBranchCoverage: '43',
                            minimumClassCoverage: '80',
                            minimumInstructionCoverage: '54',
                            maximumInstructionCoverage: '80',
                            minimumClassCoverage: '57',
                            maximumClassCoverage: '80',
                            minimumMethodCoverage: '55'
Milo
  • 3,365
  • 9
  • 30
  • 44

1 Answers1

0

What do the thresholds mean?

These minimumClassCoverage and maximumClassCoverage are the percentage of class code coverage which define whether the Jenkins build will green.

On the same documentation page from your link, you can read.

And the coverage thresholds allow to configure how much coverage is necessary to make the build green (if changing the build status is enabled).

How do we understand "class coverage"?

The good question is "what it a class coverage?".

We can understand it as one of the following:

  • What percentage of lines covered in each particular class?
  • How many classes are covered with required instruction/method percentage?
  • How many classes of all classes in the project have more than 0 coverage?

What "class coverage" actually is

The class counter is defined in JaCoCo counters documentation

From https://www.eclemma.org/jacoco/trunk/doc/counters.html:

Classes

A class is considered as executed when at least one of its methods has been executed. Note that JaCoCo considers constructors as well as static initializers as methods. As Java interface types may contain static initializers such interfaces are also considered as executable classes.

Community
  • 1
  • 1
Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34
  • Does it mean that the specific coverage - class/line/method should be above minimumCoverage and below maximumCoverage ? – Yogesh Rustagi Jul 16 '19 at 19:24
  • For class coverage, it means that the given percentage of all of classes that you examine for coverage should have at least of one method executed as written above. – Dmitriy Popov Jul 16 '19 at 20:36
  • As far as I understand from the documentation, yes, for the green build you have to be within `[minCoverage; maxCoverage]`. Although limiting `maxCoverage` looks really weird. But you can try it yourself on your Jenkins with simple project to cover (something like 1-2 classes in it). – Dmitriy Popov Jul 17 '19 at 00:40
  • Thanks, I have tried it but I am facing this issue - https://stackoverflow.com/questions/57060237/how-to-fix-unstable-builds-when-thresholds-are-met Moreover when I dont specify maxCoverage, build never fails even if coverage is below minCoverage. – Yogesh Rustagi Jul 17 '19 at 05:47