Skip to content

Instantly share code, notes, and snippets.

@cp-radhika-s
Created December 22, 2021 06:31
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 cp-radhika-s/c958274a3dbd0f483634037add6fe783 to your computer and use it in GitHub Desktop.
Save cp-radhika-s/c958274a3dbd0f483634037add6fe783 to your computer and use it in GitHub Desktop.
class MainViewModelTest {
@get:Rule
val mainCoroutineRule = MainCoroutineRule()
private val userServices = mock<UserServices>()
private lateinit var viewModel: MainViewModel
private val testDispatcher = AppDispatchers(
IO = TestCoroutineDispatcher()
)
@Test
fun `Success state works`() = runBlocking {
whenever(userServices.getUsers()).thenReturn(emptyList())
viewModel = MainViewModel(userServices, testDispatcher)
Assert.assertEquals(State.SUCCESS(emptyList()), viewModel.state.value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment