Skip to content

Coverage of default methods #905

@realdadfish

Description

@realdadfish

Steps to reproduce

JaCoCo version: 0.8.3
Operating system: macOS
Tool integration: Gradle

interface Callback {
     fun onFoo() = Unit
     fun onBar() = Unit
     fun onBaz() = Unit
}

class CallbackImpl : Callback {
      fun onFoo() { /* ... */ }
}

Expected behaviour

I'd like to see that Jacoco reports 100% coverage, because all methods in CallbackImpl are in fact covered and the default method implementations might technically be part of the class, but serve no purpose.

Actual behaviour

For a test of CallbackImpl, Jacoco will tell me that 66% of the class' methods are not covered (and one instruction per missed method as well).

One could argue that one could test to call the other methods to check if they lead to no behaviour change, but being default implementations from some base class with no actual implementation in this class I don't see why I should unit-test them here.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions