Contact us

Test Your Android App With Espresso And AWS Device Farm

aws-device-farm

App reviews make or break apps. In the current system the stars that your app users rate you with while providing the feedback, decide the fate of your app. While developing an app, patience is the key. Do not hurry. Do not upload an unstable app which has not been put through the paces. If you do, and if it crashes after users download it, users will bury it in the app stores mercilessly with bad reviews in no time.

Competition is fierce and the users are unforgiving and outspoken. Application quality is increasingly becoming a differentiator. There can be many reasons for an app crash. Memory issues, bloatware on device, network problem, inadequate error and exception handling – there can be a lot of failure points for the application. Your Android, iOS and Web Apps therefore need to be thoroughly tested on different physical devices, under different conditions, on different networks. Amazon Web Services Device Farm provides you with just the solution you are looking for to test your app the right way. It is easy to use and it is quick. When you test your app with Espresso in AWS Device Farm you will be able to figure out the issues your app has, before it is released to your users through app stores.

 

# What is AWS Device Farm?

AWS Device Farm enables you to focus on building great applications and great experiences for your users. You are not distracted by the issues that go together with the process of testing an app like building expensive device labs, building automation infrastructure, gathering different kinds of devices, ensuring they all work and remain in stable state when needed. As a mobile app testing platform AWS Device Farm handles it all efficiently for you. It helps app developers test their Apps on hundreds of devices in minutes. It hosts all these different real, non-rooted devices. You can choose the devices you want to run the tests on. You can choose the make, the model and the operating system. If you want to test different carrier connections, you can simulate the connection type and conditions using its network shaping functionality. When you schedule a run you can choose network profile like “3G”, “GPRS” or “Lossy LTE”. You can control the parameters like jitter, throughput, and loss and create the conditions you want to test the device in.

Developers can thus interact with real iOS, Fire OS and Android devices in the AWS Cloud.  AWS Device Farm supports native and hybrid Android, iOS , Web apps, cross-platform apps including the ones created with PhoneGap, Xamarin, Titanium, Unity and other frameworks. Developers can upload the apps and their test scripts and run automated tests parallely in hundreds of devices. Here is the current list of devices available with AWS Device Farm.

 

# AWS Device Farm is secure

At AWS Device Farm, security of devices that are used to test the apps, remains the focus. AWS Device Farm has been designed by keeping both its hardware and software security standpoints in mind. The devices in the farm are physically isolated from one another. There is no way someone can take a video or a picture of a device during a test. After every use the devices are wiped clean. The application under test is removed. Devices are checked for residual data. Any residual data and settings if found in the device after a testing session, is carefully deleted. If any of the safety steps fail, the device is quarantined. The devices have their own individual Wi-Fi connection. They are not connected to the same LAN so they cannot interact. There is no way for anyone from a public network to connect to the device in the farm.

 

# Devices in AWS Farm are flexible

The AWS Devices Farm is designed for enabling parallel tests in hundreds of devices the reports of which can then be aggregated. It supports both automated tests and manual interactions. You can choose a device and interact with it through your browser, touch, gesture, slide, install your app, and reproduce issues manually that have been bugging your users. You can test new features and once you script tests you can run those tests against the features and find out if everything is working correctly.

 

# AWS Device Farm Test Reports

AWS Device Farm Test reports contain test logs, device logs, crash reports, pass/fail information, screenshots, videos and performance data. You can get a detailed per device data, reports on high occurring errors. Remote access results contain different logs and video of the session. Screenshots are imbedded to the reports. You can get reports on performance data too like CPU usage, Network Tx and Rx, threadcounts and more.

 

# AWS Device Farm Integrations

You can start using AWS Device Farm by signing into the console. The console is the user interface for the AWS Device Farm. AWS Device Farm has official plugins for Jenkins, Gradle, Android Studio which you can use from your IDE. APIs of AWS Device Farm are available in SDKs in a number of available languages like Java, Python, .Net amongst others. And then you also have AWS CLI (Command Line Interface) which makes automating your processes and your scripts easier. All these available integrations make it easier for you to integrate AWS Device Farm in your workflow.

 

# AWS Device Farm Pricing

pricing-2

AWS Device Farm comes with free trial. The first 250 device minutes are provided free of charge. This one-time trial does not renew. Once the allocated 250 minutes are over, you will be billed at the standard rate of $0.17 per device minute.

Pay as you go is another option you can opt for at $0.17 per device minute. Unlimited testing starts at $250 per month.

Pricing here is based on device minutes, which are determined by the duration a test runs on a device.

AWS Device Farm also offers private devices. You can choose the make, model and operating system of the hardware. Only you will have the access to such devices.

 

# What is Android Espresso?

Espresso is one of the most used test automation framework for Android App testing. Android Espresso helps out developers who build and run test scripts for their apps. Their task is now simpler. Google has come up with Espresso Test Recorder- a tool which helps in creating tests for Android Apps easily and quickly. With the help of Espresso Test Recorder people who don’t have a background in coding or building test scripts can also generate automated user interface tests for their apps to be run on clouds – like AWS Device Farm. Android Espresso improves the efficiency of App developers and helps improve the quality of the apps.

Android Espresso is in fact a set of APIs in Android Testing Support library for writing UI tests for simulating user interactions within a single target app. Espresso Test framework runs on devices running Android 2.3.3 or above (API level 10). It automatically synchronizes test actions with the UI of application under test. It works with AndroidJUnitRunner. You can run Espresso tests locally or in clouds.

 

# Record Espresso Tests And Run Them On AWS Device Farm

You can record tests using Espresso recorder. Espresso recorder as discussed earlier is a tool that is bundled with Android Studio that lets you record your user interactions and add assertions thereby generating the tests for you. You don’t need to write a single line of code. All these tests can be run on the AWS Device Farms. You can then run the recorded tests locally and on the device farm. After running the test locally, you have to generate the APKs for the app and tests. Now you can upload the APKs and the test package to the Device Farm and you are all set to trigger the run. After you run the tests, you can analyze the results of the run with the power of AWS Device Farm.

 

# Setting The Execution Timeout For Test Runs

AWS Device Farm enables you to set the execution timeout feature on the devices you run your tests on. With the help of the API, the AWS Command Line Interface or the console, you can set an execution timeout value as low as 5 minutes. The default execution timeout is 60 minutes per device. When setting up the execution timeout option for devices you should set the option for the maximum duration you think a test run would require and then add some buffer. If your tests take 10 minutes to complete, choose a timeout of 15 minutes per device. This is to ensure if execution exceeds your expected timeout the test runs are completed and the execution on that device is not forcibly terminated leaving you with partial results. You can also avoid the situations where a test run is stuck on a device for some reason and you are continuously being billed with device minutes.

 

# Executing the Test Scripts Generated By Android Espresso in Android Studio

Test scripts generated by Espresso Test Recorder can be executed in Android Studio using real Android devices in AWS Device Farm. AWS Device Farm that has Android devices from different regions, different forms, different OS systems can provide the optimal testing environment for your apps. With Espresso Test Recorder, scripts are built easily and quickly; execution of test scripts is also the fastest when compared with other Android test automation networks like Appium, Calabash, Robotium etc. The light-weight API ensures tests remain easily maintainable and are easy to tweak.

 

# Setting up a test run on Device Farm

When you schedule a test run on AWS Device Farm, you first choose the application you want to run the test on. You can choose and upload the APK of the Android App you want to run the tests on. Name the test run. You then need to configure the test. After configuring the test you need to choose the devices you want to run the test on. Once you go to the designated section to choose the device, you would see a curated auto populated list of devices that are chosen for you. This list of devices is based on customer demand and customer usage. It is constantly updated. You can select devices and have your own device pool. You then choose the network profile you want to run your tests on. Last step is reviewing. Here you add the specifics on execution timeout feature. You confirm the details and you are set to run the test. Device farm provides you videos and screenshots of the test which provide you ample clues about the performance of your app.

 

# How are the developers actually using AWS Device Farm?

Developers have been frequently using AWS Device Farms to test iterative changes during development. They test cumulative builds which are part of continuous integration. Developers are also testing different functionalities to ensure the functionalities work on targeted devices. They set up automated canaries that run periodic tests using the API of AWS Device Farm to monitor applications to ensure the applications are able to communicate with their backend systems. AWS Device Farm is the best place to reproduce the issues reported by analytics and end users using automation, remote access feature or manually. The test reports generated are comprehensive and help the developers immensely. Experienced teams of developers and testers can help you with automated testing with AWS Device Farms.

 

Winding Up

Android Espresso can really help the developers in testing their Apps both locally and in the cloud setup like AWS Device Farm. Better testing tools ensure that you are able to make good quality apps. Iron out potential app issues with Android Espresso with the help of AWS Device Farm and get good reviews from your app users. And that is all from my desk for now. Adios.

Source

Priyanka Garg

Priyanka Garg

A writer, a wordsmith. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for OpenXcell - A Mobile App Development Company. Loves Jazz and Blues.