-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
BugBug issue typeBug issue typeCheck In JaCoCoS: postponedStatus: work on the issue is not in the short term plansStatus: work on the issue is not in the short term plans
Description
Kover incorrectly reports a gap in branch coverage
Consider this class:
class KoverExample {
private val map = mapOf<Int, () -> String>(
1 to { "Fred" },
2 to { "Joe" }
)
fun greeting(i: Int): String =
map[i]
?.invoke()
?: throw IllegalStateException("No greeting for $i")
}
and these tests:
class KoverExampleTest {
val koverExample = KoverExample()
@Test
fun `when index exists, greet`() {
koverExample.greeting(1) shouldBe "Fred"
}
@Test
fun `when index does not exist, throw`() {
shouldThrow<IllegalStateException> {
koverExample.greeting(-1)
}
}
}
Kover reports only 75% branch coverage, highlighting map[i]
as not covered.
Expected behavior
Kover should report full coverage in this example, in my opinion, given there is no code path not exercised with the test.
Reproducer
See code above.
Reports
Environment
- Kover Gradle Plugin version: 0.9.1
- Gradle version: 8.12
- Kotlin project type: Kotlin/JVM
- Coverage Toolset (if customized in build script): Kove
lucas-livefront, brian-livefront, taufikamaryansyah, paper2 and igorwojda
Metadata
Metadata
Assignees
Labels
BugBug issue typeBug issue typeCheck In JaCoCoS: postponedStatus: work on the issue is not in the short term plansStatus: work on the issue is not in the short term plans