by Uzi Eilon
Execute Espresso Tests on Perfecto Devices
Espresso is an open source framework provided by Google which allows to execute UI tests on Android apps.
It is an instrumentation-based API and works with the
AndroidJUnitRunner test runner.
After instrument the app the tool provide easy way to access the objects and execute actions and validations.
Setup the Espresso
In order to add Espresso test to your project you should :
1. Install it , by adding the lib to the gradle file:
2. Instrument the app ,by adding this line to your gradle file:
Building the app with the following configuration will open the Espresso API and you can start write your tests.
How to write Espresso tests?
Espresso commands are sync with the UI and wait for the elements.
The command build from the following steps:
- onView(object identifier) - wait for the element to appear in the UI.
- perform - execute actions in the element
- check - validation
Example - The following test open the Calc app enter percentage values and validate the results:
Device in perfecto system while the test is running
- Perfecto cloud allows you to execute your existing Espresso tests on any real devices with any Android version.
- Perfecto system generates rich report include the test video so you can get more details on your test.
- Visual validation - Espresso tests work on the objects but can't validate the if the objects display properly.
Perfecto allows you to add visual validation to avoid the following issue:
Same app - rotate device
only visual validation can find the bug above
How to start ?
In order to execute the Espresso test from command line you should use Espresso Executecommand :
New command named "Espresso Execute" added.
- Application Package Name
The command executes the test via shell command on the device and shows the results in Perfecto reports.