Skip to content

Instantly share code, notes, and snippets.

@mcatta
Created March 22, 2020 15:54
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 mcatta/3839aa24efade18bba3a5b1bec74fe1b to your computer and use it in GitHub Desktop.
Save mcatta/3839aa24efade18bba3a5b1bec74fe1b to your computer and use it in GitHub Desktop.
Test an exception
@Test
fun `Test fetchData with an exception`() {
every { dataRepository.fetchData() } throws IllegalStateException("Houston we have a problem")
mainPresenter.fetchData()
verify(exactly = 0) { view.onResult(any()) }
verify(exactly = 1) { view.onError(any()) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment