Per Jansson
10/21/2022, 7:41 AMmodifier = Modifier.testTag("HomeButton")
Test
// I've tried different ways of finding objects and different ways of waiting, but nothing seems to make the tests less flaky
@Test
fun verifyAllPages() {
device.wait(Until.findObject(By.res("HomeButton")), DEFAULT_WAIT_TIME).click()
device.wait(Until.findObject(By.res("MenuButton")), DEFAULT_WAIT_TIME).click()
device.wait(Until.findObject(By.res("MenuItem_1")), DEFAULT_WAIT_TIME).click()
...
...
...
}
Questions that I have
1. Is this really how flaky UI Automator test are expected to be, or am I missing something?
2. What alternatives do I have if I want to write a test that visits all, or at least some, of the screens in the app?
3. How are people in general testing the Android apps? Coming from the web world it is common to build high level, “opaque box” tests using e.g. Cypress or Playwright.czuckie
10/21/2022, 8:24 AMMobileElement
instances.
The Appium tests though IN MY EXPERIENCE should only be used very sparingly. On the project I was on, we had test driven the entire project (living the dream) and the main bugs we had in production were around mistakes we made using proguard. So to cover the most important journeys (sign up) we would use Appium to test the proguarded build, albeit it was pointing at a sandbox environment.czuckie
10/21/2022, 8:28 AMInstantExecutionTestRule
and the runTest
test helper that lets you get a controllable Dispatcher
instance.czuckie
10/21/2022, 8:30 AMcreateAndroidComposeRule<YourMainActivity>()
and then use the rule.onNode...
APIs to find nodes in your application and interact with them.Per Jansson
10/21/2022, 8:44 AMczuckie
10/21/2022, 9:10 AMPer Jansson
10/21/2022, 1:59 PMczuckie
10/21/2022, 3:03 PMcomposeTestRule.waitForIdle()
(Where composeTestRule is the name of your compose test rule field). I think that's it for my ninja tricks.