UIAutomator running with espresso

2020-04-10 00:58发布

问题:

I am currently testing an application that should be set as the default launcher.

I already have a set of Espresso tests running, but they only work if the user has previously selected my app as the launcher.

The dialog that appears to the user so that he can select the launcher is not reachable by Espresso, since it is outside the app itself. However, UIAutomator would be perfectly able to interact with it.

Hence, I would like to know if it is possible to use some kind of UIAutomator script before the Espresso tests.

回答1:

Since UIAutomator 2.0 is now based on Android Instrumentation, you can run Espresso and UIAutomator tests in one test suite, for example. You can play with test methods naming to run UIAutomator tests first and then run other Espresso stuff. More about UIAutomator 2.0 and how to use it together with Espresso here.



回答2:

I have no experience yet with uiatomator, but I can provide you some useful links to start. Here they are:

To get more information about uiautomator visit these site:

  • https://google.github.io/android-testing-support-library/docs/uiautomator/index.html
  • http://developer.android.com/intl/es/training/testing/ui-testing/uiautomator-testing.html
  • http://www.tutorialspoint.com/android/android_ui_testing.htm

If you're looking for how to integrate Espresso with uiatomator visit:

https://testyour.app/blog/espresso-uiautomator

Hope it help