4

I am using MockK for testing. Language: Kotlin. I have a sealed class A with a few subclasses, say B, C, and D, which is used as a parameter for a function call. I need to make sure that a function is called with one of the subtypes of A. For that I tried to do this: verify { instance.doSomething(any<B>())} and it passes. However, I tried to do any<C> and any<D> and it still passes.

How do I verify that the function was called with a parameter of type B and only B?

Sermilion
  • 1,920
  • 3
  • 35
  • 54

1 Answers1

13

Maybe ofType(type) is what you need.

João Dias
  • 16,277
  • 6
  • 33
  • 45