For Android development teams using the Espresso test framework, Perfecto DevTunnel 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.

Prerequisites

  1. Install Android Studio
    https://developer.android.com/studio/index.html
  2. Install Perfecto plugin for Android Studio
    http://developers.perfectomobile.com/display/PD/Android+Studio
  3. Download sample app (.apk) - https://github.com/PerfectoCode/AndroidDemoApp

Download the app as .zip file and extract it.

 

Run Espresso Test on a Mobile Device

  1. Open the android-calculator-master app project.
  2. Click the ‘Launch Mobile’ button within the Perfecto Android Studio plugin toolbar

     

  3. Select an Android device and click “open”
  4. Switch to the Widgets menu and click the ‘DevTunnel’ widget
  5. If you have not done so already, download and install the DevTunnel installer, and wait for installation to complete.
  6. Click the ‘Start Dev Tunnel Session’ to establish a direct connection to the device
  7. Navigate to ‘SimpleTest’ under ‘app > src > androidTest’ folder in Project navigator
  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

  1. Right-click on ‘SimpleTest’ and select ‘Run SimpleTest
  2. Select the Android device you opened from the Perfecto Lab plugin and click ‘OK’ to launch the app on that device
  3. 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
  4. When finished, click the ‘Disconnect’ button from the Perfecto plugin Widgets to close your DevTunnel session
  5. Click the ‘X’ on the device window to release the mobile device

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.