Skip to main content
Version: 5.9 🚧

Jacoco

Kotest integrates with Jacoco for code coverage in the standard gradle way. You can read gradle installation instructions here.

  1. In gradle, add jacoco to your plugins.
plugins {
...
jacoco
...
}
  1. Configure jacoco
jacoco {
toolVersion = "0.8.7"
reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir') // optional
}
  1. Add the jacoco XML report task.
tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required.set(true)
}
}
  1. 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.