package worlds.gregs.hestia.core.plugins.dialogue.systems
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
internal class SuspendTest {
interface Suspendable {
suspend fun suspend()
}
fun calledElsewhere(mock: Suspendable) = runBlocking {
mock.suspend()
}
@Test
fun `Suspend test`() = runBlocking {
//Given
val mock = mock(Suspendable::class.java)
`when`(mock.suspend()).thenReturn(Unit)
//When
calledElsewhere(mock)
//Then
Mockito.verify(mock).suspend()
}
}
Argument(s) are different! Wanted:
suspendable.suspend(
Continuation at worlds.gregs.hestia.core.plugins.dialogue.systems.SuspendTest$Suspend test$1.invokeSuspend(SuspendTest.kt:27)
);
-> at worlds.gregs.hestia.core.plugins.dialogue.systems.SuspendTest$Suspend test$1.invokeSuspend(SuspendTest.kt:27)
Actual invocation has different arguments:
suspendable.suspend(
Continuation at worlds.gregs.hestia.core.plugins.dialogue.systems.SuspendTest$calledElsewhere$1.invokeSuspend(SuspendTest.kt:16)
);
-> at worlds.gregs.hestia.core.plugins.dialogue.systems.SuspendTest$calledElsewhere$1.invokeSuspend(SuspendTest.kt:16)
verify(mock).suspend()
Minimum reproducible example: