Martin Devillers
08/21/2018, 12:54 PMInvalidUseOfMatchersException because the call mixes matches and raw values. This is because the continuation instance in the Java call is always passed directly.
Is this correct? Is there any known workaround? I’m currently mocking classes which expose suspending methods manually, but the syntax isn’t very clear. I’d rather use Mockito to keep the tests readable.
Example of failing test:
interface SuspendingAction {
suspend fun invoke(any: Any)
}
@Test
fun `verify with mockito`() = runBlocking {
val mock = Mockito.mock(SuspendingAction::class.java)
mock.invoke(Any())
Mockito.verify(mock).invoke(any())
}
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
2 matchers expected, 1 recorded: