Hil All, so i have a Robolectric test that uses an...
# coroutines
m
Hil All, so i have a Robolectric test that uses an ActivityScenario. In that activity • There is a view model that does a polling loop, using the
delay
function in between calls • My test code uses the function
composeTestRule.waitUntilExactlyOneExists
What i'm experiencing is that the ``composeTestRule.waitUntilExactlyOneExists`` is blocking the main test thread, which is expected, but it's also blocking the thread that the viewModelScope is executing on. As a result, the
delay
function never returns, and the polling loop is just sitting there blocked. I can overcome this by overriding the main dispatcher, but it seems counter intuitive that the ComposeTestRule and the view model scope in the robolectric engine would use the same underlying dispatcher .
Copy code
@Before
    fun setup() {
        Dispatchers.setMain(<http://Dispatchers.IO|Dispatchers.IO>)
    }
Has anyone experienced this and/or has a more elegant way to handle this? I would think that robolectric would isolate these two things from each other.