-
-
Save zsmb13/c9f95d19cacbb04944ce16773e533a2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@get:Rule | |
val mainDispatcherRule = MainDispatcherRule() | |
@Test | |
-fun collectingTest() = coroutineRule.runBlockingTest { | |
+fun collectingTest() = runTest { | |
- val collectJob = launch { | |
+ val collectJob = launch(UnconfinedTestDispatcher()) { | |
viewModel.state.collect { | |
// Save collected values somewhere... | |
} | |
} | |
// Emit values and assert on them here... | |
collectJob.cancel() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment