mardi 27 mars 2018

Android P Preview breaks UiAutomator tests with API compatibility error

I am trying out Android P preview on Pixel device, and currently experiencing an issue with instrumentation tests written with UiAutomator framework.

Whenever a button click is simulated with UiAutomator by following code:

onView(withId(R.id.button_activity_login)).perform(click())

I am encountering an AlertDialog with message

Detected problems with API compatibility (visit g.co/dev/appcompat for more info)

which leads to this link:

https://developer.android.com/preview/restrictions-non-sdk-interfaces.html#differentiating_between_sdk_and_non-sdk_interfaces

This breaks UiAutomator tests since my tests currently do not consider additional AlertDialog between each action.

This only happens with UiAutomator's button click, not with Espresso's. I believe that UiAutomator might use some reflections under the hood in order to achieve cross-app testing functionality (not knowing the UI component's texts or ids beforehand), whereas Espresso takes care of everything inside the app being tested.

This is somewhat weird since UiAutomator is a testing framework Google itself suggests in their developer sites (https://developer.android.com/training/testing/ui-automator.html#ui-automator-apis). Does anybody have experienced or solved the following issue?

Aucun commentaire:

Enregistrer un commentaire