Compose & Espresso UI Testing
TESTING › UI
Writing instrumented UI tests for Compose semantics and View-based screens with Espresso.
UI testing questions probe whether you can write reliable, non-flaky instrumented tests for both Compose and legacy View screens. Interviewers check that you understand the Compose semantics tree, finders/actions/assertions, and Espresso's onView/perform/check pattern. A recurring theme is automatic synchronization and idling resources, since flaky tests are a top real-world pain point.
What this covers
- Compose rules: createComposeRule vs createAndroidComposeRule and setContent
- Finders, actions, and assertions: onNodeWithText, performClick, assertIsDisplayed
- The semantics tree, Modifier.testTag, and useUnmergedTree
- Espresso's onView(matcher).perform(action).check(assertion) pattern
- How both frameworks auto-synchronize with the UI and the role of IdlingResource
- Correct test dependencies and the AndroidJUnitRunner for instrumented tests
Study this topic
- Compose & Espresso UI Testing explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Compose & Espresso UI Testing interview questions and answers