Colton Idle
12/22/2023, 3:16 PMcloseableScope.launch {
}
and now that I did that, my test times out. if i remove the blah.collectLatest {}
then it passes. Anyone have tips on what to do in this scenario. im still a rookie when it comes to testing, especially coroutines/flowsmkrussel
12/22/2023, 3:30 PMrunTests
waits for all child jobs to finish. If nothing cancels the launched job and if the flow doesn't complete, then the job will keep running and the test will time out.franztesca
12/22/2023, 3:32 PMrunTest
one.mkrussel
12/22/2023, 3:41 PMColton Idle
12/22/2023, 3:50 PMColton Idle
12/22/2023, 3:51 PMHomeViewModel(
appStateHolder = fakeAppStateHolder,
closeableScope = CloseableCoroutineScope(backgroundScope.coroutineContext),
Peter Farlow
01/02/2024, 2:59 PMrunTest
function is totally fine, but if you do, make sure you don’t also call val scope = TestScope()
anywhere in else in test file. If you need a reference to a TestScope, you can instantiate one yourself and instead use fun myTest = testScope.runTest { }
instead of the top-level runTest
function.
https://slack-chats.kotlinlang.org/t/3157046/the-android-coroutine-testing-https-developer-android-com-ko