Espresso(Android UI tests) cheats sheet

Formula:

  • Espresso — Entry point to interactions with views (via onView and onData). Also exposes APIs that are not necessarily tied to any view (e.g. pressBack).
  • ViewMatchers — A collection of objects that implement Matcher<? super View> interface. You can pass one or more of these to the onView method to locate a view within the current view hierarchy.
  • ViewActions — A collection of ViewActions that can be passed to the ViewInteraction.perform() method (for example,click()).
  • ViewAssertions — A collection of ViewAssertions that can be passed the ViewInteraction.check() method. Most of the time, you will use the matches assertion, which uses a View matcher to assert the state of the currently selected view.