I’m using jacoco for code coverage. My problem is, I am getting a xml generated report, however I am not getting any html report, nor am I getting the jacoco-session.html
Here is my config:
tasks.withType<Test> {
useJUnitPlatform()
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = true
excludes = mutableListOf("jdk.internal.*")
}
}
afterEvaluate {
android.applicationVariants.forEach { variant ->
val variantName = variant.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.ENGLISH) else it.toString() }
val testTaskName = "test${variantName}UnitTest"
val reportTask = tasks.create("jacoco${testTaskName}Report", JacocoReport::class.java) {
dependsOn(testTaskName)
group = "Reporting"
description = "Generate Jacoco coverage reports for the $variantName build."
reports {
xml.required.set(true)
html.required.set(true)
}
classDirectories.setFrom(
files(
fileTree(variant.javaCompileProvider.get().destinationDir) {
exclude(fileFilter)
},
fileTree("${project.layout.buildDirectory}/tmp/kotlin-classes/${variantName}") {
exclude(fileFilter)
}
)
)
sourceDirectories.setFrom( variant.sourceSets.flatMap { it.javaDirectories })
executionData.setFrom(file("${project.layout.buildDirectory}/jacoco/$testTaskName.exec"))
}
tasks.findByName("jacocoTestReport")!!.dependsOn(reportTask)
}
}
tasks.register("jacocoTestReport")
This all looks to be correct (to me) but I’m obviously going wrong somewhere on this. If anyone could shed some light or provide some help I would be eternally grateful.