Closed ecgreb closed 4 years ago
I was hoping that using runBlockingTest()
would force the DB flow to emit before finishing the test but it appears there is still a race condition between .collect { summary -> viewUpdate(summary) }
in BreedModel
and assertNotNull(itemDataSummary)
in the test.
When I run locally sometimes it passes and sometimes the test fails.
Any ideas how to wait for the DB flow to emit before executing the assertion without resorting to sleep/delay statements? @russhwolf @kpgalligan
runBlockingTest()
only exists for JVM anyway, so that isn't going to work. The iOS tests don't compile in this branch.
As to the particular test issues, I haven't looked super closely but one approach is to grab the Job
from any internal launch
calls and join()
it, which will suspend until it completes. That should work fine inside runBlocking()
(which we expose to common via runTest()
) but any delay()
calls would not get sped up.
Overview
Adds tests for
BreedModel
view update and error update callbacks.Proposed Changes
runTestWithFlow
based onkotlinx.coroutines.test.runBlockingTest
.