Eugen Martynov
01/29/2021, 9:30 AMprivate val testCoroutineDispatcher = TestCoroutineDispatcher()
private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher)
I try to run suspend function in it
fun runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) =
testCoroutineScope.runBlockingTest { block() }
And particular is
dispatcherRule.runBlockingTest {
val msg = Gallery.Effects.LoadGallery.run.invoke(this, Gallery.Deps(photoGalleryManager))
assertThat(msg).isEqualTo(Gallery.Msg.FilesLoaded(failure))
}
I’m getting
This job is not completed yet
Even if I change it to:
private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher + Job())
I still get that exception, what can I do?
If I run test inside the global scope then test passbohsen
01/29/2021, 9:42 AMrunBlocking
.
kotlinx-coroutines-test
artifact definitely needs some work.bohsen
01/29/2021, 9:44 AMEugen Martynov
01/29/2021, 9:57 AMEugen Martynov
01/29/2021, 10:22 AMrunBlocking(GlobalScope.coroutineContext) {
val msg = suspendedFunction() assertThat(msg).isEqualTo(Gallery.Msg.FilesLoaded(failure))
}