Skip to content

[Kotlin] The last case in when for seal object is never show coverage without already test #704

@thuypt

Description

@thuypt

I wrote a when condition for seal object and implement test for all cases, but Jacoco doesn't show coverage for the last case.

ex:
Code

        when (index) {
            is Index.First -> instayWifi.clear()
            is Index.Second -> instayWifi.setUpInStayWifiCredential()
        }

Test

       whenSampleCoverrage.apply(Index.Second)
        verify(instayWifi).setUpInStayWifiCredential()

        whenSampleCoverrage.apply(Index.First)
        verify(instayWifi).clear()

In the coverrage result, it doesn't show coverage for last case
screen shot 2018-06-29 at 11 59 09 am

JaCoCo version: 0.8.1
Operating system: MacOS
Tool integration: AndroidStudio/Gradle/Java/Kotlin

Expected behaviour

The last case in when should show coverage after call testing.

Actual behaviour

The last case in when never show coverage after call testing.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions