hello folks :wave: given the function: ```fun <...
# server
l
hello folks 👋 given the function:
Copy code
fun <T : Any> myFunction(foo: Foo, bar: Bar, response: KClass<T>): MyResponse<T> { do magic }
how can it be mocked to control the returned object?
Copy code
whenever(mockedClass.myFunction(any(), any(), any<SomeType>())).thenReturn(MyResponse<SomeType>())
I tried few variations with mockito/mokk but the argument matcher never works.
j
with mockk it should be
Copy code
every { mockedClass.myFunction(any(), any(), ofType(SomeType::class) } returns SomeType()
A bit hard to say when your example doesn't quite match up (Any vs SomeType)
j
l
@Jordan Foo it didn't work
Copy code
Type mismatch.
Required: KClass<TypeVariable(T)>
Found: SomeType