If jacocoTestCoverageVerification fails, coverage report is not written? [SOLVED]


(Adhamh Findlay) #1

Hi,

I have the below jacoco setup with gradle 3.4.1 or 3.5. When my jacocoTestCoverageVerification task fails the build, the code coverage report is not generated. Is there a way get it generated? I ask because that’s really helpful in determining where I need more tests to get my lines covered up to the minimum.

jacocoTestCoverageVerification {
    violationRules {
        rule {
            limit {
                counter = "LINE"
                minimum = 0.90
            }
        }
    }
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.enabled true
    }
}

check.dependsOn jacocoTestReport
check.dependsOn jacocoTestCoverageVerification

(James Justinic) #2

Unless you’re using --continue, the default behavior is to stop everything on first failure. They’re not running in your preferred order with just configuring check to depend on both, so you just need to configure them as you want. Using mustRunAfter or shouldRunAfter probably models your intention more accurately than dependsOn here.

jacocoTestCoverageVerification.mustRunAfter jacocoTestReport

Alternatively, if you really want to see this report, even if tests fail, you could also model this as a finalizer task of the Test task that generates the JaCoCo data that you’re reporting on.

test.finalizedBy jacocoTestReport

(Adhamh Findlay) #3

Thanks @jjustinic. That did it! Now, I can see that my coverage is failing because org.gradle is being included.

ask about that here: Why is org.gradle included in my jacoco test coverage?