Skip to content

100% branch coverage cannot be met when the suspend method return value is kotlin.Result #1868

@gkj17

Description

@gkj17
  • JaCoCo version: 0.8.12.202403310830
  • Operating system: Windows11
  • Tool integration: Maven
  • Complete executable reproducer:
// kotlin code
suspend fun process(scenarioId: Int, trigger: Int): Result<Unit>

process(
     scenarioId = //anyIntValue,
     trigger = //anyIntValue
)
// UT code

// case1
coEvery {
    scenarioStateDispatcher.process(any(), any())
}.returns(Result.success(Unit))

// case2
coEvery {
    scenarioStateDispatcher.process(any(), any())
}.returns(Result.failure(Exception("test Exception")))

  • Steps: (what exactly are you doing with the above reproducer?)
    I want the process method to implement 100% branch coverage.

Expected behaviour

100% branch coverage of process method.

Actual behaviour

1 of 2 branches missed.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions