Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created July 10, 2022 09:56
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/996f2d8efef5d466e832b6c6bb47040d to your computer and use it in GitHub Desktop.
Save hongbeomi/996f2d8efef5d466e832b6c6bb47040d to your computer and use it in GitHub Desktop.
@Test
fun fetchData_loading() {
// 메인 디스패처를 게으르게 시작하는 디스패처로 교체
Dispatchers.setMain(StandardTestDispatcher())
// 데이터 가져오기
viewModel.fetch()
// 로딩 상태 체크
assertEquals(true, viewModel.loading.getOrAwaitValue())
// 예약되어 있던 작업 실행
advanceUntilIdle()
// 로딩 상태 체크
assertEquals(false, viewModel.loading.getOrAwaitValue())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment