For Android development teams using the Espresso Android test framework, Perfecto's Remote Device Access feature provides the ability to run tests on real devices and under realistic conditions. This enables developers to quickly debug code under test, fix failing tests, and resolve test flakiness issues on multiple real devices and end user environments.


  1. Install Android Studio
  2. Install Perfecto plugin for Android Studio
  3. Download sample app (.apk)

Download the app as .zip file and extract it.

Image Debug Native Android Screen 1

Run Espresso Test on a Mobile Device

1. Open the android-calculator-master app project.

2. Click the ‘Launch Mobile’ icon in the Perfecto Android Studio plugin toolbar.

Image Debug Native Android Screen 2

3. Select an Android device and click “open”

Image Debug Native Android Screen 3

 4. Switch to the Widgets menu and click the ‘DevTunnel’ widget.

Image Debug Native Android Screen 4

5. If you have not done so already, download and install the DevTunnel installer, and wait for the installation to complete. 

Image Debug Native Android Screen 5

6. Click the ‘Start Dev Tunnel Session’ step to establish a direct connection to the device.

Image Debug Native Android Screen 6

7. Navigate to ‘SimpleTest’ under ‘app > src > androidTest’ folder in Project navigator.

Image Step 7 Espresso Simple Test

8. Before executing the test, you can leverage Perfecto Lab capabilities to configure the device environment using the widgets – change the network, location, or install additional applications on the device to validate multiple end user environments. 

Image Step 8 Espresso Configure Device

9. Right-click on ‘SimpleTest’ and select ‘Run SimpleTest’ 

Image Step 9 Espresso Run Test

10. Select the Android device you opened from the Perfecto Lab plugin and click ‘OK’ to launch the app on that device. 

Image Debug Native Android Screen 10

11. After Gradle build is successful, note that Android Studio utilizes ADB commands against the device to copy the .apk resources to the device, launch the app, and run your Espresso test. 

Image Step 11 Espresso Gradle Test

12. When finished, click the ‘Disconnect’ button from the Perfecto plugin Widgets to close your DevTunnel session. 

Image Step 12 Disconnect Web App Devtunnel

13. Click the ‘X’ on the device window to release the mobile device.

Image Step 13 Release Device Web App Devtunnel

Congratulations! You now know how to connect a real, cloud-based mobile device from the Perfecto Lab into your IDE. Try it out with the next feature you’re building or run some of your own tests on different devices to see if your apps pass with flying colors on other platforms.