Closed alwa closed 3 years ago
It's verify
or verifyBlocking
with mockito-kotlin
:
@Test
fun verifySuspendFunctionCalled() {
runBlocking {
/* Given */
val m = mock<SomeInterface>()
/* When */
m.suspending() }
/* Then */
verify(m).suspending()
}
}
...
@Test
fun verifySuspendFunctionCalled_verifyBlocking() {
val m = mock<SomeInterface>()
runBlocking { m.suspending() }
verifyBlocking(m) { suspending() }
}
Closing per the above. Thanks for the explanation @bohsen !
I've read the wiki and there is no example how to verify that a suspend function has been called.
Is this implemented?
In Mockk the equivalent is called "coVerify()", see: https://mockk.io/