Discrepancy in Jacoco test report

Viewed 52

I have a grade project and I have excluded certain files from Jacoco reporting. When I run the command gradle jacocoTestReport. Below output is shown.

Test Coverage:
    - Class Coverage: 84.2%
    - Method Coverage: 80%
    - Branch Coverage: 59.1%
    - Line Coverage: 81.8%
    - Instruction Coverage: 80.8%
    - Complexity Coverage: 62.7%

But when i run gradle build. I get the below error:-

Execution failed for task ':project:jacocoTestCoverageVerification'.
> Rule violated for bundle project: instructions covered ratio is 0.5, but expected minimum is 0.8

build.gradle:-

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it,  exclude: [
                    "com/project/commons/infrastructure/**"
            ])
        }))
    }
    finalizedBy jacocoTestCoverageVerification
}

jacocoTestCoverageVerification {
    violationRules {
        rule {
            limit {
                minimum = 0.8
            }
        }
    }
}

Can anyone please tell me why is there a discrepancy ?

0 Answers
Related