kotlinx-kover icon indicating copy to clipboard operation
kotlinx-kover copied to clipboard

[XML] Codecov.io does not see files with package mismatch

Open IgnatBeresnev opened this issue 1 year ago • 1 comments

If you have a Kotlin file with some classes/functions under a certain package, for example

src/main/kotlin/org/jetbrains/kover/reproducer/PackageMismatchFile.kt

but inside the file you have a different package declared, for example

package org.jetbrains.kover.reproducer.some.inner.pckg // some.inner.pckg has been added

class PackageMismatchClass {}

codecov.io will not see (and thus not calculate coverage for) this file. You can observe it in this report.

If you physically move the file to the "correct" package, it will work as expected.

The problem might be relevant for other tools that use Jacoco format since this behaviour is not possible in Java (package must match location), and tools that analyze Jacoco coverage reports might rely on that.


I haven't noticed any difference in generated XML reports between Jacoco and IntelliJ engines, both generate the following paths:

    <package name="org/jetbrains/kover/reproducer/some/inner/pckg">
        <class name="org/jetbrains/kover/reproducer/some/inner/pckg/PackageMismatchClass"
               sourcefilename="PackageMismatchFile.kt">
            ...
        </class>
        <sourcefile name="PackageMismatchFile.kt">
            ...
        </sourcefile>
        ...
    </package>

Runnable reproducer can be found in this repo, there are instructions on how to run it and upload the report.

This was found while investigating https://github.com/Kotlin/kotlinx-kover/issues/16

IgnatBeresnev avatar Oct 20 '22 09:10 IgnatBeresnev

For more context, related JaCoCo issue: https://github.com/jacoco/jacoco/issues/939

twyatt avatar Mar 02 '23 06:03 twyatt