julioromano
02/28/2024, 9:58 AM@Test
fun `sample test`() = runTest {
launchMolecule(RecompositionMode.Immediate) {
// no-op
}
}
This the debug log:
After waiting for 1m, the test coroutine is not completing, there were active child jobs: ["coroutine#3":StandaloneCoroutine{Active}@c1a65a7, JobImpl{Active}@2fc7cf1d, "coroutine#4":StandaloneCoroutine{Active}@3b5b1500]
kotlinx.coroutines.test.UncompletedCoroutinesError: After waiting for 1m, the test coroutine is not completing, there were active child jobs: ["coroutine#3":StandaloneCoroutine{Active}@c1a65a7, JobImpl{Active}@2fc7cf1d, "coroutine#4":StandaloneCoroutine{Active}@3b5b1500]
at app//kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$2$1.invoke(TestBuilders.kt:351)
at app//kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$2$1.invoke(TestBuilders.kt:335)
at app//kotlinx.coroutines.InvokeOnCancelling.invoke(JobSupport.kt:1428)
at app//kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1473)
at app//kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:796)
at app//kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:756)
at app//kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:672)
at app//kotlinx.coroutines.JobSupport.cancelCoroutine(JobSupport.kt:659)
at app//kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:156)
at app//kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:498)
at app//kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
at app//kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:105)
at java.base@17.0.10/java.lang.Thread.run(Thread.java:840)
The project is using Android and Jetpack Compose, so only molecule-runtime is imported.
All libraries are updated to their most recent version as of now (though I also tried to downgrade molecule as well as compose and compose compiler but nothing changed).
It is most probably not molecule's fault as the same setup is working in many other projects of mine but I can't figure out what's wrong in this one.jw
02/28/2024, 11:45 AMbackgroundScope
to launch it.julioromano
02/28/2024, 1:24 PM@Test
fun `sample test`() = runTest {
backgroundScope.launchMolecule(RecompositionMode.Immediate) {
// no-op
}
}
julioromano
02/28/2024, 1:24 PMjulioromano
02/28/2024, 1:25 PMjulioromano
02/28/2024, 1:25 PMbackgroundScope
and do work. Have I just been lucky?julioromano
02/28/2024, 1:30 PMmoleculeFlow
in the other projects' tests, not launchMolecule
.julioromano
02/28/2024, 1:31 PM