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.
- Install Android Studio
- Install Perfecto plugin for Android Studio
- 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
- Open the android-calculator-master app project.
- Click the ‘Launch Mobile’ button within the Perfecto Android Studio plugin toolbar
- Select an Android device and click “open”
- Switch to the Widgets menu and click the ‘DevTunnel’ widget
- If you have not done so already, download and install the DevTunnel installer, and wait for installation to complete.
- Click the ‘Start Dev Tunnel Session’ to establish a direct connection to the device
- Navigate to ‘SimpleTest’ under ‘app > src > androidTest’ folder in Project navigator
- 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
- Right-click on ‘SimpleTest’ and select ‘Run SimpleTest’
- Select the Android device you opened from the Perfecto Lab plugin and click ‘OK’ to launch the app on that device
- 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
- When finished, click the ‘Disconnect’ button from the Perfecto plugin Widgets to close your DevTunnel session
- 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.