Android Testing UI with Espresso

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

Espresso

Espresso cheat sheet will help you write your tests and what you want to test:

https://google.github.io/android-testing-support-library/docs/espresso/cheatsheet/

Also always a good place for reference is the official documentation:

https://google.github.io/android-testing-support-library/docs/espresso/index.html

Advanced espresso video suggestions by Google: https://www.youtube.com/watch?v=isihPOY2vS4

Troubleshooting

  • When trying to scroll, be sure to close the keyboard first:

Watchout: not using the "Espresso" version won't do anything when used outside a ViewAction. This may not be obvious if you have an import on the ViewAction version since they have exactly the same method name.

ViewActions.closeSoftKeyboard;
Espresso.closeSoftKeyboard();
  • When running tests together in a suite rather than individually, be aware that the Activity from the previous test may still be running. Do not rely on the previous test's onDestroy() being called before the current tests onResume(). It turns out this is actually a bug: http://b.android.com/201513


Got any Android Question?