Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

Missing coverage for public extension method #561

Open Faltenreich opened 2 months ago

Faltenreich commented 2 months ago

Describe the bug Kover shows zero coverage for a public extension method.

Errors Kover shows a different coverage than Android Studio's "Run with Coverage".

Expected behavior Kover should show the same coverage as Android Studio's "Run with Coverage".

Reproducer

// src/main/kotlin/<package>/SampleExtensions.kt
// interesting: displayed as "SampleExtensionsKt" in Kover's HTML report
fun Sample.doSomethingInExtension() { ... } // Kover: 0% coverage
// src/main/kotlin/<package>/SampleViewModel.kt
// displayed as "SampleViewModel" in Kover's HTML report
class SampleViewModel {
    fun doSomethingInViewModel() {
        Sample().doSomethingInExtension() // Kover: 100% coverage
    }
}
// src/test/kotlin/<package>/SampleViewModelSpec
class SampleViewModelSpec : io.kotest.core.spec.style.WordSpec() {
    init {
        "SampleViewModel" should {
            "call extension" {
                SampleViewModel().doSomethingInViewModel()
            }
        }
    }
}

Environment

shanshin commented 2 months ago

Hi, could you check in the 0.7.6 version?

If the error is going to be reproduced, could you provide a small reproducer project? I was unable to reproduce the error locally.