Describe the bug
We are still on kover 0.6.1 but migrated to Gradle 8.6 (AGP 8.4.0). The command ./gradlew koverXmlReport runs all the tests but the final report shows "No Coverage Information found".
I understand there are newer kover versions, but is this expected to happen?
Here's the setup:
build.gradle(top-level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'versions.gradle'
apply from: 'dependencies.gradle'
apply from: 'config.gradle'
repositories {
google()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:${versions.gradle}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin_version}"
classpath "org.jetbrains.kotlinx:kover:${versions.kover}"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${versions.sonarqube_version}"
}
}
allprojects {
repositories {
google()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
apply from: "$rootProject.projectDir/coverageConfig.gradle"
def isJacocoEnabled = System.getProperty("JACOCO_ENABLED", "false")
def coverageEngine = isJacocoEnabled == "true" ?
kotlinx.kover.api.DefaultJacocoEngine.INSTANCE :
kotlinx.kover.api.DefaultIntellijEngine.INSTANCE
kover {
engine = coverageEngine
filters {
// common class filter for all default Kover tasks in this project
classes {
excludes.addAll(coverageExcludeClasses)
}
annotations {
excludes.addAll(coverageExcludeAnnotations)
}
}
}
}
apply from: 'sonarqube.gradle'
apply from: 'coverage.gradle'
coverageConfig.gradle
// Can't place variables in coverage.gradle because they have to also be included in the main build.gradle
// for all projects
def coverageExcludeAnnotations = [
"androidx.compose.runtime.Composable"
]
ext.coverageExcludeAnnotations = coverageExcludeAnnotations
def coverageExcludeClasses = [
// Android
"androidx.*",
...
]
ext.coverageExcludeClasses = coverageExcludeClasses
def coverageExcludeProjects = [
// modules that can be skipped since they don't have unit tests
..
":modules:common:testing",
]
ext.coverageExcludeProjects = coverageExcludeProjects
Here's the coverage.gradle
koverMerged {
enable()
filters {
classes {
excludes.addAll(coverageExcludeClasses)
}
annotations {
excludes.addAll(coverageExcludeAnnotations)
}
projects {
// Specifies the projects excluded in the merged tasks
excludes.addAll(coverageExcludeProjects)
}
}
}
// source: https://github.com/Kotlin/kotlinx-kover/issues/18#issuecomment-1307196785
def startTaskNames = gradle.getStartParameter().getTaskRequests().collect {
TaskExecutionRequest req -> req.args
}.flatten()
println(startTaskNames)
if (startTaskNames.any { it.contains('kover') }) {
def allowedUnitTestNames = [
"testDebugUnitTest", // this task should cover all the rest of the modules
"testABCProdDebugUnitTest" // specific for the main app module
]
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
android.testOptions.unitTests.all {
if (project.hasProperty("kover") &&
!allowedUnitTestNames.contains(name)
) {
kover {
isDisabled.set(true)
}
}
}
}
}
}
}
tasks.getByPath('sonar').setDependsOn([])
tasks.getByPath('sonar').setMustRunAfter([])
Errors
None present. All the test run successfully, but the XML report is empty as shown below.
Expected behavior
Code coverage % should remain unchanged.
Reproducer
Unfortunately the code is closed source. If this behavior is not expected I can try to create a sample project.
Hi,
unfortunately, the compatibility of outdated versions of Kover with the latest versions of AGP is not tested and therefore is not guaranteed.
If possible, try to upgrade to 0.8.0
Describe the bug We are still on kover 0.6.1 but migrated to Gradle 8.6 (AGP 8.4.0). The command
./gradlew koverXmlReport
runs all the tests but the final report shows "No Coverage Information found".I understand there are newer kover versions, but is this expected to happen?
Here's the setup:
build.gradle(top-level)
coverageConfig.gradle
Here's the coverage.gradle
Errors None present. All the test run successfully, but the XML report is empty as shown below.
Expected behavior Code coverage % should remain unchanged.
Reproducer Unfortunately the code is closed source. If this behavior is not expected I can try to create a sample project.
Reports coverage.html
coverage.xml
Environment