In Espresso, we mainly have three components:
ViewMatchers: Allows you to find a view in the current view hierarchy. This can be done in various ways, such as searching by id, name, child, and so on. You can also use Hamcrest matchers, such as containsString.
ViewActions: Allows you to perform actions on the views, such as clicking, typing, clearing text, and so on.
ViewAssertions: Allows you to assert the state of a view that checks whether the condition under the view assertion passes.
Let's take a look at the following steps to understand acceptance testing using Espresso:
- Here's an example of a text matcher (a text matcher matches the text; it's a part of ViewMatchers):