Is there any tool to measure test coverage in the common portion of a Kotlin multiplatform project? I'm investigating migrating a Kotlin project to multiplatform. I'm a TDD developer and the code has 98% coverage. A good 95% can move to common. Am I looking at abandoning coverage metrics?
kotlin multiplatform coverage? [closed]
Asked Answered
I just opened a feature request for this on IDEA's bugtracker: youtrack.jetbrains.com/issue/IDEA-241030 –
Exile
I have also a multiplatform kotlin project that uses jacoco for test coverage.
just follow this guide
but there's a need for a little configuration in case you are using gradle kotlin dsl:
plugins {
kotlin("multiplatform") version "1.3.72"
id("java-library")
jacoco
}
jacoco {
toolVersion = "0.8.6"
}
tasks.jacocoTestReport {
val coverageSourceDirs = arrayOf(
"src/commonMain",
"src/jvmMain"
)
val classFiles = File("${buildDir}/classes/kotlin/jvm/")
.walkBottomUp()
.toSet()
classDirectories.setFrom(classFiles)
sourceDirectories.setFrom(files(coverageSourceDirs))
executionData
.setFrom(files("${buildDir}/jacoco/jvmTest.exec"))
reports {
xml.isEnabled = true
html.isEnabled = true
}
}
running the command below will generate reports on your build/reports/test/jacoco
gradle clean build jacocoTestReport
@Both do not hesitate to mark an answer as correct if it helped you! –
Knorring
try this: https://github.com/Kotlin/kotlinx-kover (Gradle plugin for Kotlin code coverage agents: IntelliJ and JaCoCo.)
© 2022 - 2024 — McMap. All rights reserved.