Turbine is very handily tool for test flows. But I have an issue when convert live data to flow like:
fun foo(
): Flow<B> =
bar().asFlow()
.map { -> }
And then in test class: @ExperimentalCoroutinesApi val testDispatcher: TestDispatcher = StandardTestDispatcher()
@ExperimentalCoroutinesApi
val testScope: TestScope = TestScope(testDispatcher)
@Before
fun init() {
Dispatchers.setMain(testDispatcher)
}
@Test
fun testFoo() = testScope.runTest {
foo().test{
val result = awaitItem()
Assert.assertEquals(expected, result)
awaitComplete()
}
}
Then I got this error
After waiting for 60000 ms, the test coroutine is not completing, there were active child jobs: [ScopeCoroutine{Active}@35c3ef4a]
Previously I faced this issue and find out that in some case should awaitComplete() but it some case that will also not works.