Skip to content

Instantly share code, notes, and snippets.

@u0705666
Created July 19, 2023 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u0705666/6f3bd5e6ac03db8bacd155c4263ea14f to your computer and use it in GitHub Desktop.
Save u0705666/6f3bd5e6ac03db8bacd155c4263ea14f to your computer and use it in GitHub Desktop.
unit test coWhenever
fun <T> coWhenever(block: suspend CoroutineScope.() -> T): OngoingStubbing<T> =
runBlocking {
whenever(block())
}
fun <T> coVerify(mock: T, block: suspend CoroutineScope.(T) -> Unit) {
runBlocking {
block(verify(mock))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment