Using `AndroidComposeTestRule` , I'm trying a basi...
# test
o
Using
AndroidComposeTestRule
, I'm trying a basic E2E scenario on my app. The main content stays blank (I get top app bar, bottom nav etc.) until the test finishes, despite using the
waitUntil*
helpers. I have 2 steps in the start sequence to load content:
null
(loading), then
List<T>
(empty or not), the first step remains until test end but never change before that. The state relies on a Room database
Flow
from a
Dao
. What could prevent the Room flow mechanism to operate in the context of Compose UI tests?
1
On Compose side, I'm using
Copy code
val content by viewModel.content.collectAsState(null)
Hmm… It appears that adding
Copy code
= runTest {}
around the test solves the issue… I'm not sure I spotted that anywhere, but might be logical if Room behavior is tweaked in test context (which feels a bit weird for E2E maybe, no?)
c
Hey! This seems to be an Android question, maybe ask in #C0B8M7BUY or #C1CFAFJSK? There isn't really enough information in your message to understand what the problem could be.
o
The issue came from coroutines managed by Room weren't resumed because execution under test (compose test rule behavior I guess). Adding
runTest{}
solved the issue as answered to myself. Totally linked to #C0NBD4UF8 IMO even if, yes, linked to #C1CFAFJSK as well.
c
Yeah, no problem. It's just, this channel is usually used for methodology questions, and usually technical questions don't get an answer because they depend on a specific technology that people here don't necessarily know 👍
👍 1
o
Wasn't aware about that indeed 👍 🙇