Skip to content

Instantly share code, notes, and snippets.

@micHar
Created June 21, 2022 07:00
Show Gist options
  • Save micHar/1b3dc08ab94b2a5cabcb7c1b2e18f058 to your computer and use it in GitHub Desktop.
Save micHar/1b3dc08ab94b2a5cabcb7c1b2e18f058 to your computer and use it in GitHub Desktop.
@OptIn(ExperimentalCoroutinesApi::class)
class NeverEndingCoroutineTest {
@Test
fun `should emit error when playSound throws`() = runTest {
val exception = Exception("Oopsie")
val soundPlayer = mockk<SoundPlayer>()
coEvery { soundPlayer.playSound() } throws exception
val sut = MediaPlayer(this, soundPlayer)
sut.playerErrors.test {
sut.play()
awaitItem() shouldBe exception
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment