Why is org.gradle included in my jacoco test coverage?


(Adhamh Findlay) #1

Hi,

My jacocoTestCoverageVerification is failing our build because its including org.gradle. I’m using gradle 3.5. I’ve tried to exclude these packages, but it’s not working. I’ve only get 29% line coverage because, understandably, I’m not testing anything in the org.gradle packages. Any suggestions? thx

Any suggestions?

jacocoTestCoverageVerification {
    violationRules {
        rule {
            excludes = ['org.gradle.*']
            limit {
                counter = "LINE"
                minimum = 0.90
            }
        }
    }
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.enabled true
        html.destination "${rootDir}/.tempReports/${task.project.name}/"
    }
    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it,
            excludes: [
                    'org/gradle/**'
            ])
        })
    }
}

If jacocoTestCoverageVerification fails, coverage report is not written? [SOLVED]
(Adhamh Findlay) #2

I think I know why this is happening… I’m creating a project generator and in src/main/resources I’m included the gradle wrapper jar so the clients can download it. The appears to be putting the jar on the classpath so jacoco is reporting on it. Still not sure how to fix it.


(Soner Sari) #3

I agree with you @adhamh


(Adhamh Findlay) #4

I filed an issue: https://github.com/gradle/gradle/issues/1957