Luiz Aguiar
03/20/2021, 11:30 AMfun <T : Any> myFunction(foo: Foo, bar: Bar, response: KClass<T>): MyResponse<T> { do magic }
how can it be mocked to control the returned object?
I tried something like:
every { mockedClass.myFunction(any(), any(), ofType(SomeType::class) } returns SomeType()
but it didn't work... and using the type directly, myFunction(any(), any(), SomeType::class)
is never matched.ephemient
03/20/2021, 5:13 PMofType()
? that would match a SomeType
, not a KClass<SomeType>
ephemient
03/20/2021, 5:14 PMmockedClass.myFunction(any(), any(), SomeType::class)
should workephemient
03/20/2021, 5:21 PMKClass<out SomeType>
, you'd have to write a custom matcher, like
myFunction(any(), any(), match<KClass<*>>(SomeType::class::isSuperclassOf))
Luiz Aguiar
03/21/2021, 10:58 PMmyFunction(any(), any(), SomeType::class)
is never matched… only returns null
for it