0

I have a simple isSubClass function which takes in a List of Classes and a Throwable and returns true if any of the Classes in the list is a subclass of the throwable and false otherwise.

Jacoco shows the function with a green mark saying all braches covered. Yet in the table, it shows Coverage being only 75%

What's wrong here?

private fun isSubClass(exceptionList: List<Class<out Throwable>>, throwable: Throwable): Boolean {
        return exceptionList.any { throwable::class.isSubclassOf(it.kotlin) }
}

enter image description here

enter image description here

  • I tested your method against an empty list, a matching exception and not matching. Report: 100% code coverage, 1 line of code. But your coverage picture shows 4 Lines for `isSubClass`. Is it the whole code in the picture? – ocos Jul 29 '22 at 17:02
  • `any` is acting like an `if` statement here: do your tests run both the `true` and the `false` cases? This is what "branches" refers to when it comes to code coverage. – Can_of_awe Jul 29 '22 at 17:13
  • @ocos Thanks for taking time to reply to my message. Yes 1 line of code. Just now I'm seeing Lines = 4 I'm equally puzzled why Lines = 4 is being shown here. – Gladwin Rojer Aug 08 '22 at 14:03

0 Answers0