Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created July 10, 2022 09:52
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 hongbeomi/5db3e3788e0766f0af258fd52e19abeb to your computer and use it in GitHub Desktop.
Save hongbeomi/5db3e3788e0766f0af258fd52e19abeb to your computer and use it in GitHub Desktop.
@Test
fun fetchData_loading() {
// 메인 디스패처 정지를 위해 pause
mainCoroutineRule.pauseDispatcher()
// 데이터 가져오기
viewModel.fetch()
// 로딩 상태 체크
assertEquals(true, viewModel.loading.getOrAwaitValue())
// 메인 디스패처 다시 시작을 위해 resume
mainCoroutineRule.resumeDispatcher()
// 로딩 상태 체크
assertEquals(false, viewModel.loading.getOrAwaitValue())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment