Jacoco
Kotest integrates with Jacoco for code coverage in the standard gradle way. You can read gradle installation instructions here.
- In gradle, add jacoco to your plugins.
plugins {
...
jacoco
...
}
- Configure jacoco
jacoco {
toolVersion = "0.8.7"
reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir') // optional
}
- Add the jacoco XML report task.
tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required.set(true)
}
}
- Change tests task to depend on jacoco.
tasks.test {
...
finalizedBy(tasks.jacocoTestReport)
}
Now when you run test
, the Jacoco report files should be generated in $buildDir/reports/jacoco
.
note
You may need to apply the jacoco plugin to each submodule if you have a multi module project.