Test Your Ionic App on Real Android and iOS Devices with AWS Device Farm
Bryan Segale is a specialist in mobile testing and test automation for AWS Mobile.
We live in a world in which the variety of device manufacturers, models, operating systems, and screen sizes combine to create a device test matrix that is seemingly infinite in size. Ionic takes care of a lot of the heavy lifting, and combined with testing on real devices, you can make sure your customers have a great user experience, no matter where they are or what device they’re using.
AWS Device Farm enables you to securely test your Android and iOS apps on real devices in the AWS Cloud. As you’re developing and testing your Ionic app, you can see how it works on a variety of devices with AWS Device Farm. Device Farm allows you to take full control of a remote device, install your app, and perform your tests through your browser.
Testing on a wide variety of real devices ensures that there aren’t app issues caused by variations in device hardware, OS version, or rendering issues for devices with different screen resolutions. Mobile users aren’t tolerant of bugs, and negative app reviews will lead to fewer downloads.
In addition, you can execute automated tests in parallel written in a variety of popular automation frameworks. Test automation will increase the accuracy and speed with which you can test your app and help you get your app to market faster.
Your first 250 device minutes using Device Farm are free. Here’s more information on getting started testing your app in Device Farm.
Prepare your Ionic app for AWS Device Farm
To test your Ionic App in AWS Device Farm, you must create a native Package build for your targeted platform. For Android, the file must be an .apk (Android application package). For iOS, the file must be an .ipa (iPhone application archive file) build for a device, not the simulator.
To build and package your Ionic App for Android in preparation for testing on AWS Device Farm:
* Review and install the necessary platform dependencies.
* Add the Android platform to your Ionic project with the following Command Line Interface (CLI) command: ionic platform add android
* Build and package your Ionic App into the an .apk file with the following CLI command: ionic build android
* Once the build is complete, your .apk file will be located in the platforms/android/build/outputs/apk/ directory of your Ionic project folder. The packaged .apk in this directory is the file needed to upload to the AWS Device Farm when creating a test run.
To build and package your Ionic App for iOS in preparation for testing on AWS Device Farm:
* Review and install the necessary platform dependencies.
* Add the Android platform to your Ionic project with the following Command Line Interface (CLI) command: ionic platform add ios
* Build and package your Ionic App into the an .ipa file with the following CLI command: ionic build ios
Once the build is complete, your .ipa file will be located in the platforms/ios/build/device directory of your Ionic project folder. The .ipa file in this directory is the file needed to upload to the AWS Device Farm when creating a test run. Apple requires all iOS apps to be code signed to launch on a device. Since you will be launching your packaged Ionic App as an iOS app on real devices in AWS Device Farm, you will need to ensure your generated .ipa file is properly code signed. Please review the Cordova documentation for more information on code signing your iOS app to create a signed .ipa file for devices.
Install and interactively test your app
Follow the instructions to set up your AWS account and get started with AWS Device Farm. To test your Android or iOS app, simply open a new session by selecting the device manufacturer, make and model, OS version, and carrier variant of the device with which you’d like to interact. The remainder of this post will use an Android app for demonstration purposes. The steps to test an iOS application are the same, except you will upload an .ipa file instead of an .apk file.
Once the remote session is established with the device, install your app using the Upload button in the Install applications panel on the right side of the screen. For Android, upload your .apk file located in the platforms/android/build/outputs/apk/ directory of your Ionic project folder. This will upload and install your application to the device. For iOS, upload the .ipa file located in the platforms/ios/build/device directory of your Ionic project folder.
Once your app is uploaded, processed, and installed, you can launch your application from the Apps Drawer on the Android device. This examples uses the git2it sample app.
Now you can gesture, swipe, and interact with the device in real time directly through your web browser, as if it was on your desk or in your hand.
At the end of the session, device logs can be viewed in the AWS console or downloaded for offline viewing. A video recording of the device session is available in the Files tab.
Run automated tests against your app
AWS Device Farm allows you to execute test scripts you’ve written in a number of popular automation frameworks (For example, Appium, Calabash, Espresso, uiautomator, XCTest, and UI Testing in XCode) on 100s of real devices. Devices are available on-demand, and tests execute in parallel on your selected devices. Test reports include high-level results, screenshots, recorded video, device logs, performance data, and step-by-step execution logs. You can also integrate AWS Device Farm into your development workflow, using our Jenkins and Gradle plugins, or build your own with our SDKs and CLI.
To get started with automation, simply schedule a new run and upload your app.
Then select the type of test you’d like to execute.
Then choose the devices on which to execute your tests.
Finally, optionally configure the location, locale, and other settings on the device.
Your test scripts will execute in parallel on the chosen devices, and your report will be built as results are available.
Test results include a report summary (pass/fail), device logs, performance data, screenshots and a video recording of the device during the test.
Report Summary
Device Logs
Performance Data
Screenshots
Video Recording
Conclusion
To get started testing your app in Device Farm or for more information on the service, visit this page. And remember, your first 250 device minutes are free. Good luck!