unbroken-dome / gradle-testsets-plugin

A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
MIT License
230 stars 50 forks source link

Testset specific JaCoCo exec files unused #115

Closed Arc-E-Tect closed 3 years ago

Arc-E-Tect commented 3 years ago

Got to testsets created

testSets {
    bddTest { dirName = 'bdd-test' }
    intTest { dirName = 'int-test' }
}

When running the generated tasks (gradlew bddTest intTest) the files intTest.exec and bddTest.exec are created. But the JaCoCo report is not showing the coverage from the tests in these two sets and the build fails because the jacocoTestCoverageVerification is not meeting my threshold.

What is happening here as I understand from the documentation, the necessary changes related to JaCoCo are also part of the plugin.

Thanks

Arc-E-Tect commented 3 years ago

Never mind, the solution is by defining the jacocoTestReport and jacocoTestCoverageVerification as follows:

jacocoTestReport {
    sourceSets sourceSets.main    // important!
    executionData fileTree(project.buildDir.absolutePath).include("jacoco/*.exec")
    reports {
        xml.enabled false
        csv.enabled true
        html.destination file("${buildDir}/reports/jacoco/Html")
        csv.destination file("${buildDir}/reports/jacoco/jacoco.csv")
    }
}

jacocoTestCoverageVerification {
    executionData fileTree(project.buildDir.absolutePath).include("jacoco/*.exec")
    violationRules {
        rule {
            limit {
                minimum = minCodeCoverage
            }
        }
    }
}

This does require the check to be depending on all relevant test sets otherwise the appropriate .exec files will not be available.