Kotlin / kotlinx-kover

Apache License 2.0
1.28k stars 48 forks source link

Coverage is not collected in gradle plugin test #529

Closed SurpSG closed 4 months ago

SurpSG commented 4 months ago

Describe the bug If I apply kotlin gradle plugin then coverage collecting is failed:

    @Test
    fun `apply plugin test`() {
        val project: Project = ProjectBuilder.builder().build()
        project.pluginManager.apply("org.jetbrains.kotlin.jvm") // <------- applying of the plugin fails coverage collection
        project.pluginManager.apply("org.example.plugin-with-cover")
    }

If I run this test without the kotlin plugin then the coverage is collected properly.

Errors coverage-error.log is generated in build/kover/bin-reports: coverage-error.log

Expected behavior The coverage is collected successfully

Reproducer There is an example where the issue could be reproduced.

Reports If applicable, report files or screenshots.

Environment

shanshin commented 4 months ago

Hi, thanks for the reproducer!

In the build.gradle.kts file, replace the Kover configuration

kover {
    excludeInstrumentation {
        classes("*CompileOptions*")
        packages("com.android")
        packages("*.android.*")
    }
}

with the following:

kover {
    excludeInstrumentation {
        packages("org.jetbrains.kotlin.gradle")
    }
}
SurpSG commented 4 months ago

@shanshin It works, thank you!

Closing the issue.