Replies: 1 comment 1 reply
-
IMO, we should never silently ignore this kind of null return value. This is definitely a bad testing practice and will hide potential bugs. Unfortunately,
This means that tests will fail with a semantically "wrong" device.findObject(By.text("foo")).click()
A better solution would be to create this kind of extension: fun UiDevice.getObject(selector: BySelector): UiObject2 =
findObject(selector) ?: error("Object not found for: $selector") And using it like this: device.getObject(By.text("foo")).click() will produce this error message:
In this project, we already have this kind of extension that behaves similarly |
Beta Was this translation helpful? Give feedback.
-
On my personal project as well as the nowinandroid project, I have experienced sometimes the baseline generator/macrobenchmark fails to find this object sometimes.
Do we expect the test to fail and crash the app(stopping after the last iteration) or skip the process when the object is not found and continue with the tests.
Why not use this?
Beta Was this translation helpful? Give feedback.
All reactions