How to call a lambda callback with mockk
You can use answers: val otm: ObjectToMock = mockk() every { otm.methodToCall(any(), any())} answers { secondArg<(String) -> Unit>().invoke(“anything”) } otm.methodToCall(“bla”){ println(“invoked with $it”) //invoked with anything } Within the answers scope you can access firstArg, secondArg etc and get it in the expected type by providing it as a generic argument. Note that I explicitly … Read more