Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import io.reactivex.Single
import io.reactivex.schedulers.TestScheduler
import org.junit.Test
@Test
fun `GIVEN unsuccessful data fetch WHEN screen opens THEN display error`() {
val view: MainScreenContract.View = mockk(relaxed = true)
val fetchCurrencyUseCase: FetchCurrencyUseCase = mockk {
every { execute() } returns Single.error(Throwable("error occurred"))
}
val presenter = MainScreenPresenter(
fetchCurrencyUseCase = fetchCurrencyUseCase,
schedulerProvider = TrampolineTestSchedulers()
)
presenter.attach(view)
verify {
view.displayError(any())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment