Kotlin / kotlinx-kover

Apache License 2.0
1.27k stars 47 forks source link

Confusing log output from Jacoco when showing coverage results #544

Open realdadfish opened 3 months ago

realdadfish commented 3 months ago

It seems to me as if the Jacoco Ant task to check for coverage get's the percent value of the coverage reported, while it needs to work with the floating point value. Anyways, this is what I see:

> Task :my-component:app:koverLog
[ant:jacocoReport] Rule violated for bundle :app: lines covered ratio is 0.2664, but expected minimum is 1.0000

> Task :my-component:app:koverPrintCoverage
:app line coverage: 26.64%

The expected coverage for this module is 28%, with a threshold of 5%, i.e.

val minBound = (expected - threshold).coerceAtLeast(0)
val maxBound = (expected + threshold).coerceAtMost(100)

so the minBound should be 23 and the maxBound should be 33. The extension is then configured like this:

koverReport {
    verify {
        rule {
            minBound(minBound)
            maxBound(maxBound)
       }
    }
}

The koverVerify task also runs through as expected, just the log output is confusing.

Environment

shanshin commented 3 months ago

For now, you can ignore the output of the task koverLog and analyze only logs from koverPrintCoverage.

In JaCoCo, the coverage value is now obtained through verification, and so far it is not very clear how to disable logging into stderr :(.

Later, we will try to explore how we can disable JaCoCo err logging or find another easy way to get values.