Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

Suspend functions break branches coverage #691

Closed zhkvdm closed 1 month ago

zhkvdm commented 1 month ago

Describe the bug Branches coverage is wrong then call suspend functions. Suspend function break coverage to half. But I check all posible branches. Branches coverage is ok if I call the same non suspend function. Just delete suspend codeword.

Expected behavior Branches coverage is not depends on function type (suspend/non suspend)

Reports Coverage check with suspend function call:

suspend

Coverage check with non suspend function call:

non suspend

Environment

zhkvdm commented 1 month ago

@shanshin Hello! Any comments to this issue? Do you reproduce the bug?

shanshin commented 1 month ago

@zhkvdm, unfortunately, it was not possible to reproduce it locally.

var testVar: Int = 0

suspend fun testFun() {
    testVar = getTestData()
}

private suspend fun getTestData() = 1

Generated report

Screenshot 2024-10-17 at 16 43 44
zhkvdm commented 1 month ago

Okay, in new empty project it works well. Looks like it is project specific issue..

zhkvdm commented 1 month ago

Find the way how to reproduce this. Just add jacoco. Without jacoco everything is okay.