Mobile Testing with AWS: Using AWS Device Farm

AWS Device Farm is a testing service for mobile app developers using Android, iOS, or Amazon Fire OS apps. Announced at the regional AWS Summit in New York City in July 2015, AWS Device Farm allows developers to simultaneously test applications on a wide range of devices including smartphones, tablets and more, in the cloud. Developers can simply upload their apps and test them on a variety of devices for the latest device/OS combination.

In this post, we’re going to walk you through the process of setting up and using AWS Device Farm.

Overview

Before we get into the how-to, let’s take a closer look at the problems that AWS Device Farm solves.

Because many developers rely on manual testing for their applications, this phase can be extremely time consuming and complex, especially given the large variety of devices on the Android market, not to mention the multiple variations of models, OS versions, carrier customizations, and more. This makes it difficult to access or even successfully simulate 100% of what’s available.
AWS Device Farm addresses this challenge by providing a test environment that covers all of the available combinations of devices and operating systems. It does not use simulators, but real non-rooted devices.

This access to the latest hardware, operating systems, and platforms allows the testing process to be more streamlined, less expensive, and more innovative. According to the official press release announcing the service, “Developers can use AWS Device Farm to test real-world customer scenarios, fine-tuning test environments with a broad set of device configurations, including language, location, app data, and app dependencies.” It can identify errors across multiple devices and presents you with the data to analyze events across even hundreds of tests.

In terms of pricing, AWS Device Farm offers a free plan for the first 250 device minutes. Thereafter, you pay $0.17 per device minute. You can also pay a flat $250 per device per month for an unlimited testing time.

For the full list of devices, pricing, documentation, and more visit the official AWS Device Farm page.
Mobile App Testing on Devices – AWS Device Farm

Getting Started

Before creating our project in AWS Device Farm, you will need to make sure that you have an AWS account. AWS recommends that instead of using your AWS root account to access the service, you should create a new IAM (Identity and Access Management) user (unless you already have one. You will need to set up permission for the IAM user to access Device Farm by creating a new access policy in IAM.

Now, let’s get started with our project.

The first step is to create a new project, which is a workspace inside AWS Device Farm. A project collects all of the Runs executed inside it. According to AWS, in this context, a run “represents a specific build of your app, with a specific set of tests, to be run on a specific set of devices.” Here, it provides a variety of ways to track the results of our tests. Projects are not differentiated by the operating system, application, or tests type. However, a Run is, so we can run a test case for Android and one for iOS inside the same project or even test two different apps. Since the are no limits for the number of projects we can create, it’s always better to differentiate on the operating system, the application, or both.
Screen Shot 2017-01-17 at 10.41.38
Once the project is created, we can start with our first suite of tests executed on a pool of devices; in other words, our first Run. First of all, we need to choose the type of application that we want to test. Because we’ll focus exclusively on iOS and Android applications in this post, we will need to choose native (iOS or Android).

Next, we need to upload the application that we want to test. For Android, we need to export a .apk file from the debug configuration (on release all tests are removed). For iOS we need a .ipa.

We need to archive our project (be sure to run the archive command with a real device or “generic iOS device” selected) and then export it choosing “Save for development deployment”. Once finished we can upload it.upload

Configure a Test

Now we can configure our tests. There are a lot of options available but we can choose only one for each Run. External frameworks like Appium or  Cabalash are supported along with XCTest, XCUITest, and Instrumentation along with a Fuzz test.
fuzzyTest
Let’s focus on the last one. The goal of a fuzz test (or fuzzing) is to stress the app with large amounts of random data that might make it crash in order to discover any errors or loopholes. No additional files are required. Simply select Built in: Fuzz and we are ready to go.

Note: If you plan to execute a Fuzz test on your iOS app, make sure that you have iOS 9.0 as a minimum target since Fuzz tests do not work on iOS versions 10.0.1+. (At this time, there no devices with iOS 10.0.0 or 10.0.1. They start from iOS 10.0.2.)

Device Pool

The device pool is the container of devices where our tests will runs. In Device Farm, a device pool “represents a collection of devices that typically share similar characteristics such as platform, manufacturer, or model.” A curated pool of “Top Devices” is available out of the box or we can build our own. The list of available devices is quite large covering all iOS devices (from iOS 8.0 onward) plus a good selection of Android devices. You can find the most diffused devices, like the Samsung Galaxy and Nexus along with some Amazon Fire devices. There is also the possibility to suggest a device to add to the pool of available ones.

You can also define some simple rules to automatically include certain devices, like “All android tablet” or “All Samsung devices”
!aAWS Device Farm
There are no limits on how many devices you can include in a pool, but the tests will run simultaneously on 5 devices maximum.

Run our own tests

As stated above device farm supports a large number of test suites. How tests are uploaded is different from platform to platform. While on Android device is sufficient to upload a test .apk (that can easily be generated with Android studio) on iOS we have different cases if we want XCTests or XCUITests. For XCTests we need to upload a zip containing our .xctest, instead of for XCUITests we need a .ipa file.
AndroidTestUpload loadedTest
The files we need can be found in Library/Developer/XCode/DerivedData/My-App/Build/products/debug-iPhone. XCTest files are located in the package my-app-name.  Open the package (Show package content) and find the .xctest file in the Plugin directory. For XCUITest you need to compress the package my-app-name-Runner and change the extension from .zip to .ipa.
Also, remember that in debug XCode build only for the current hardware architecture. This can lead to test errors if you try to run a test on a device with a different architecture from yours.
Screen Shot 2017-01-17 at 12.09.38

Test Results

We can now run our test. The test will run in parallel on every device in the pool. The total time of a test is calculated as the sum of the time spent by each device. This is the time Amazon will bill to you, bigger the device pool bigger the time we are going to spent.
test succeded
When the tests are completed we will be presented with a nice recap view. For each device, we can see which tests have succeeded and which have failed, plus detailed information about the device. Everything is recorded, we can access to performance graphs showing FPS, CPU, Memory and Threads plus all device logs and a video showing the device screen. This is especially useful during UI or Fuzz testing to better identify the problem.
Video fullPageCrop

Pricing

The base pricing plan is 0.17$ per device minute. That is if you run a test on two devices in parallel and each one takes 5 minutes to complete you will spend (5 + 5) * 0.17 = 1.7$. If your tests take a lot of times or involve a great number of devices, there is also a flat plan for 250$/month which let you run as many tests as you want.

Remote Device

An interesting feature is the possibility to connect remotely to a specific device model via a remote screen and install our app. This is particularly useful if you need to test on a particular device (to reproduce a bug for example) although the experience is not smooth as it should be, with a notable lag on the device screen.
RemoteDeviceAndroid

Conclusion

Device Farm is surely a service worth of trying especially if you have your own test suite. It is easy to use and offer a very detailed recap view, providing all information need to reproduce the bug. Its strong point is the possibility to execute tests on a wide range of devices, allow us to discover problems which could not be seen on our test devices. This is very handy especially on Android where is difficult to cover a lot of devices due to its big device fragmentation. The documentation part is a bit lacking in how to export test for iOS (especially where to find them) and on some non-code related errors (like when you are trying to upload an ipa compiled for a different architecture). The remote device feature is cool, but currently, it’s usability is the only average due to the high lag between input and device response.

Download our new Cloud Academy app now!
Get it on Google PlayDownload on the App Store

Avatar

Written by

Luca Faverio

Luca is a Software Engineer, passionate about mobile technologies and travels he is currently responsible for the iOS application at Cloud Academy.


Related Posts

Joe Nemer
Joe Nemer
— September 15, 2020

New Content: Azure DP-100 Certification, Alibaba Cloud Certified Associate Prep, 13 Security Labs, and Much More

This past month our Content Team served up a heaping spoonful of new and updated content. Not only did our experts release the brand new Azure DP-100 Certification Learning Path, but they also created 18 new hands-on labs — and so much more! New content on Cloud Academy At any time, y...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Joe Nemer
Joe Nemer
— August 28, 2020

AWS Certification Practice Exam: What to Expect from Test Questions

If you’re building applications on the AWS cloud or looking to get started in cloud computing, certification is a way to build deep knowledge in key services unique to the AWS platform. AWS currently offers 12 certifications that cover major cloud roles including Solutions Architect, De...

Read more
  • AWS
  • AWS Certifications
Patrick Navarro
Patrick Navarro
— August 25, 2020

Overcoming Unprecedented Business Challenges with AWS

From auto-scaling applications with high availability to video conferencing that’s used by everyone, every day —  cloud technology has never been more popular or in-demand. But what does this mean for experienced cloud professionals and the challenges they face as they carve out a new p...

Read more
  • AWS
  • Cloud Adoption
  • digital transformation
Avatar
Andrew Larkin
— August 18, 2020

Constant Content: Cloud Academy’s Q3 2020 Roadmap

Hello —  Andy Larkin here, VP of Content at Cloud Academy. I am pleased to release our roadmap for the next three months of 2020 — August through October. Let me walk you through the content we have planned for you and how this content can help you gain skills, get certified, and...

Read more
  • alibaba
  • AWS
  • Azure
  • content roadmap
  • Content updates
  • DevOps
  • GCP
  • Google Cloud
  • New content
Alisha Reyes
Alisha Reyes
— August 5, 2020

New Content: Alibaba, Azure AZ-303 and AZ-304, Site Reliability Engineering (SRE) Foundation, Python 3 Programming, 16 Hands-on Labs, and Much More

This month our Content Team did an amazing job at publishing and updating a ton of new content. Not only did our experts release the brand new AZ-303 and AZ-304 Certification Learning Paths, but they also created 16 new hands-on labs — and so much more! New content on Cloud Academy At...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Alisha Reyes
Alisha Reyes
— July 16, 2020

Blog Digest: Which Certifications Should I Get?, The 12 Microsoft Azure Certifications, 6 Ways to Prevent a Data Breach, and More

This month, we were excited to announce that Cloud Academy was recognized in the G2 Summer 2020 reports! These reports highlight the top-rated solutions in the industry, as chosen by the source that matters most: customers. We're grateful to have been nominated as a High Performer in se...

Read more
  • AWS
  • Azure
  • blog digest
  • Certifications
  • Cloud Academy
  • OWASP
  • OWASP Top 10
  • Security
  • VPCs
Avatar
Cloud Academy Team
— July 9, 2020

Which Certifications Should I Get?

The old AWS slogan, “Cloud is the new normal” is indeed a reality today. Really, cloud has been the new normal for a while now and getting credentials has become an increasingly effective way to quickly showcase your abilities to recruiters and companies. With all that in mind, the s...

Read more
  • AWS
  • Azure
  • Certifications
  • Cloud Computing
  • Google Cloud Platform
Alisha Reyes
Alisha Reyes
— July 2, 2020

New Content: AWS, Azure, Typescript, Java, Docker, 13 New Labs, and Much More

This month, our Content Team released a whopping 13 new labs in real cloud environments! If you haven't tried out our labs, you might not understand why we think that number is so impressive. Our labs are not “simulated” experiences — they are real cloud environments using accounts on A...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Joe Nemer
Joe Nemer
— June 19, 2020

Kickstart Your Tech Training With a Free Week on Cloud Academy

Are you looking to make a jump in your technical career? Want to get trained or certified on AWS, Azure, Google Cloud Platform, DevOps, Kubernetes, Python, or another in-demand skill? Then you'll want to mark your calendar. Starting Monday, June 22 at 12:00 a.m. PDT (3:00 a.m. EDT), ...

Read more
  • AWS
  • Azure
  • cloud academy content
  • complimentary access
  • GCP
  • on the house
Alisha Reyes
Alisha Reyes
— June 11, 2020

New Content: AZ-500 and AZ-400 Updates, 3 Google Professional Exam Preps, Practical ML Learning Path, C# Programming, and More

This month, our Content Team released tons of new content and labs in real cloud environments. Not only that, but we introduced our very first highly interactive "Office Hours" webinar. This webinar, Acing the AWS Solutions Architect Associate Certification, started with a quick overvie...

Read more
  • AWS
  • Azure
  • DevOps
  • Google Cloud Platform
  • Machine Learning
  • programming
Rebecca Willis
Rebecca Willis
— June 3, 2020

Azure vs. AWS: Which Certification Provides the Brighter Future?

More and more companies are using cloud services, prompting more and more people to switch their current IT position to something cloud-related. The problem is most people only have that much time after work to learn new technologies, and there are plenty of cloud services that you can ...

Read more
  • AWS
  • Azure
  • certification
Alisha Reyes
Alisha Reyes
— June 2, 2020

Blog Digest: 5 Reasons to Get AWS Certified, OWASP Top 10, Getting Started with VPCs, Top 10 Soft Skills, and More

Thank you for being a valued member of our community! We recently sent out a short survey to understand what type of content you would like us to add to Cloud Academy, and we want to thank everyone who gave us their input. If you would like to complete the survey, it's not too late. It ...

Read more
  • AWS
  • Azure
  • blog digest
  • Certifications
  • Cloud Academy
  • OWASP
  • OWASP Top 10
  • Security
  • VPCs