kotlinx-kover
kotlinx-kover copied to clipboard
Coverage for inline functions producing flow is not working
Describe the bug
Consider the following function:
inline fun flowTest(): Flow<Int> {
return flow {
for (i in range(1, 10)) {
emit(i)
}
}
}
and the following test:
@Test
fun `flow test`() {
runBlocking {
flowTest().collect(::println)
}
}
Full coverage is expected, confirmed by the println output from the test. However, Kover reports coverage as missing for this.
Errors
Kover reports missing coverage
Expected behavior
Full coverage to be reported.
Reproducer
See code snippits above. This is a reproduction of an issue in this code: https://sonarcloud.io/component_measures?metric=new_coverage&selected=driessamyn_kapper%3Acoroutines%2Fsrc%2Fmain%2Fkotlin%2Fnet%2Fsamyn%2Fkapper%2Fcoroutines%2FKapperKotlinFlowQueryFun.kt&view=list&pullRequest=85&id=driessamyn_kapper
Environment
- Kover Gradle Plugin version: 0.9.1
- Gradle version: Gradle 8.12
- Kotlin project type: Kotlin/JVM
- Coverage Toolset Kover
Confirmed that using the Jacoco coverage library also misses this coverage
Confirmed that using the Jacoco coverage library also misses this coverage
Recent versions of JaCoCo do not support inline functions. A future release contains the necessary changes.
Closed due to the end of IntelliJ Agent development (#720) and the introduction of a new strategy for measuring of Kotlin code coverage (#746).
It is recommended to use JaCoCo, for this purpose it is enough to specify
kover {
useJacoco("0.8.13")
}
in each project.