-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build Fixes, Fix Tests #28
base: main
Are you sure you want to change the base?
Conversation
remove `runBlockingTest` use `kotlinx.coroutines.test.runTest` Return Job from addScreenToBackstack to allow tests to wait for addScreenToBackstack to complete, instead of having a test only `useDefaultDispatcher` boolean in `Repository` to force `withRepoContext` to run synchronously
Hi Luca, I am getting these exceptions when testing for Android. Any idea?
|
For some reason the second test to run fails when `runTest` is called when `Dispatchers.resetMain()` is set in the `@AfterTest` function: Caused by: java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:115) at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:96) at kotlinx.coroutines.test.internal.TestMainDispatcher.isDispatchNeeded(TestMainDispatcher.kt:31) at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:319) at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith$default(DispatchedContinuation.kt:278) at kotlinx.coroutines.DispatchedCoroutine.afterResume(Builders.common.kt:261) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
@dbaroncelli I really can't figure out why. It only happens sometimes. Half the time it succeeds... It seems like it may be some sort of bug with |
@luca992 I just made a commit: ec0793d |
OK, I just realized ProGuard is configured only for release. |
I'll try it out soon. |
I also think it's not ideal to have test only code in the actual code, but unfortunately I didn't have much time to think about a solution to this. I hope to find a cleaner solution. |
runBlockingTest
usekotlinx.coroutines.test.runTest
useDefaultDispatcher
boolean inRepository
to forcewithRepoContext
to run synchronously