Skip to content

Instantly share code, notes, and snippets.

@yasukotelin
Created November 29, 2021 08:58
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 yasukotelin/1dc1588f8dc583f658deb5cc95d736a4 to your computer and use it in GitHub Desktop.
Save yasukotelin/1dc1588f8dc583f658deb5cc95d736a4 to your computer and use it in GitHub Desktop.
/**
* Eventに値が流れてきていないことをAssertする
*/
suspend fun <T> FlowTurbine<T>.assertAwaitItemIsNotReceived() {
try {
awaitItem()
Assert.fail("Expected no event was received in time")
} catch (e: TimeoutCancellationException) {
// SharedFlowに値が流れてこないと[TimeoutCancellationException]が発生するため、それを正とする
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment