I've split my tests into unit & DB test suites using Junit5 tags. I created a new test task of called dbTest to run only those test tagged with the Db tag.

Looks like this (kotlin-dsl):

val dbTest by creating(Test::class) {
        useJUnitPlatform {
            includeTags("db")
        }  
    }

Now I'm trying to calculate the coverage of the DB tests but the jacoco report is always empty.

Jacoco creates a non-empty exec file in the build/jacoco dir called dbTest.exec. But when running the jacoco test report the resulting report is empty. I generate the DB report using a custom jacoco report task that looks like this:

val jacocoDbTestReport: JacocoReport by creating(JacocoReport::class) {
        reports {
            xml.isEnabled = true
            html.isEnabled = true
        }
        executionData(file("$buildDir/jacoco/dbTest.exec"))
    }

0 Answers