diff --git a/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt b/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt index 645bdb987..48677e68d 100644 --- a/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt +++ b/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt @@ -93,7 +93,7 @@ class BookmarksViewModelTest { @Test fun feedUiState_resourceIsViewed_setResourcesViewed() = runTest { - val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() } + backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() } // Given newsRepository.sendNewsResources(newsResourcesTestData) @@ -109,13 +109,11 @@ class BookmarksViewModelTest { val item = viewModel.feedUiState.value assertIs(item) assertTrue(item.feed.first().hasBeenViewed) - - collectJob.cancel() } @Test fun feedUiState_undoneBookmarkRemoval_bookmarkIsRestored() = runTest { - val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() } + launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() } // Given newsRepository.sendNewsResources(newsResourcesTestData) @@ -134,7 +132,5 @@ class BookmarksViewModelTest { val item = viewModel.feedUiState.value assertIs(item) assertEquals(1, item.feed.size) - - collectJob.cancel() } }