reading-notes

Espresso

Espresso is a testing framework for Android to make it easy to write reliable user interface tests

Synchronization capabilities

the following synchronization conditions are met:

  1. The message queue is empty.
  2. There are no instances of AsyncTask currently executing a task.
  3. All developer-defined idling resources are idle.

Packages

Ridiculous superpower: the Espresso Test Recorder

Record an Espresso test

  1. Espresso tests consist of two primary components

  2. UI interactions and assertions on View elements
  3. UI interactions include tap and type actions that a person may use to interact with your app

  4. Record an Espresso test
1. Click Run > Record Espresso Test.

2. In the Select Deployment Target window, choose the device on which you want to record the test.

3. Recorded interactions will appear in the main panel in the Record Your Test window, When you run the test, the Espresso test will try executing these actions in the same order.

  1. Add assertions to verify UI elements
1. Click Add Assertion.
2. To select a View element on which to create an assertion, click on the element in the screenshot or use the first drop-down menu in the Edit assertion box at the bottom of the window.
3. Select the assertion you want to use from the second drop-down menu in the Edit assertion box.
4. Click Save and Add Another to create another assertion or click Save Assertion to close the assertion panels.
  1. Save a recording ```
  2. Click Complete Recording.
  3. Use the Test class name text field if you want to change the suggested name. Click Save.
  4. Android Studio shows the test class as selected in the Project window of the IDE. ```

Additional resources

Espresso Testing

Ridiculous superpower: the Espresso Test Recorder ******