From the course: Android Espresso Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
The Espresso formula - Android Tutorial
From the course: Android Espresso Essential Training
The Espresso formula
- [Instructor] To write an Espresso test, we will be using the Espresso formula. There are three parts to the Espresso formula, onView, which takes a ViewMatcher, and then .perform, which takes a ViewAction, and .check, which takes a ViewAssertion. First, we use onView to locate a view on the screen. Once we have the view, we can perform some action on it. For example, clicking, typing, etc. We can also check that it looks as expected. We will be using the Espresso formula in our test. We will use it three times. First, we will check that the text view is empty in the beginning. Then, we will use it to perform the action click. We are going to click on the greet button. Finally, we are going to check that the TextView displays the text "Hello!" Let's write the test.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.