I am encountering an issue with my Android application's UI tests using Espresso. When I run a UI test, almost nothing is visible on the screen. However, when I normally launch the application on a device, everything is displayed correctly as expected.
It appears that Espresso UI tests cannot properly interpret the 0dp width or height value for the components set within a ConstraintLayout context, because when I change 0dp to match_parent it works! As a result, elements that rely on constraints to determine their size are not displayed during the tests.
Here are some details and steps I've taken:
the components have their constraints properly defined in the ConstraintLayout.
when the app runs on a device outside of Espresso, all elements are visible and correctly sized.
during tests, only some elements are displayed, while others (especially those with 0dp dimensions) are missing.
What I've Tried
- used ActivityScenario to launch the activity in the test.
- attempted to use IdlingResource to wait for the layout pass, but the issue persists.