A successful mobile application has two things in common. First needs to be bug-free and another is its user-friendliness. For this to come to be, every mobile application must go through rigorous testing and bug fixing. As the mobile device users increase, so does the mobile devices. So, it is imperative to test them using many scenarios. One such scenario is testing it using Cloud Technology. Specifically, using Appium test framework using AWS clouds.

With an ever-changing technology landscape of Cloud Infrastructure Management services, testing mobile applications via clouds become imperative. As per a recent survey, a whopping 95% user abandon an app in the first month due to content and engagement issues. The biggest non-content reasons for abandonment are application crashes and security concerns.

The reasons behind of using a cloud for a useful mobile testing service are: instant access to many real devices, ability to run parallel tests, excellent reporting, ability to configure the device state, and little to no modifications to your existing test setup.

AWS Device Farm is provisioned for rapid testing of Android, iOS and FireOS mobile applications on many smartphones and devices on AWS clouds. It is as simple as upload and runs to test results. A user simply needs to upload their App to test framework known as Appium and that provisions you to test your app on the go. Moreover, AWS device farm will run the tests and send you optimized reports for the test including logs, metrics, and screenshot for app performance and whether it passed the test or not.

Introduction of Appium as Mobile Automation Tool

Appium is an Open Source mobile automation testing framework. It allows automation of native, hybrid and mobile web applications for iOS, Android and Windows. Using Appium, we can execute automation test on physical mobile devices and emulator/simulator as well.

Appium supports “cross-platform” test execution, means test are written for multiple platforms (iOS, Android & Windows) use the same API.

Appium Philosophy:

  1. You shouldn’t have to recompile your app or modify it in any way in order to automate it.
  2. You shouldn’t be locked into a specific language or framework to write and run your tests.
  3. A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.
  4. A mobile automation framework should be open source, in spirit and practice as well as in name.

 

Running Appium on multiple devices simultaneously

Parallel test execution is always essential to reduce efforts and increase the productivity. Appium also supports simultaneous execution.

Let’s assume that 4 devices are connected to the PC and when you type the adb devices command, it will fetch out all the devices connected to your PC. Now to run the same Appium script on multiple devices simultaneously, you need to run multiple Appium servers. Every instance of Appium server has to be registered with the hub.

Hence to run the test on ten different devices, you need to run ten Appium nodes. Such implementation leads to high system memory consumption and it becomes more tedious when required to sync many more devices.

Plus, to buy all sorts of device available in the market & run your test on each one of them individually is expensive and difficult to maintain. To overcome this challenge we can integrate existing Appium test on suitable Device Farm. Through Device Farm, you get to access thousands of Mobile devices and Tablets available in wide range of OS versions.

Few such device farms are available in market as mentioned below:

  1. AWS Device Farm
  2. Google Cloud Test Labs
  3. Xamarin Test Cloud
  4. Sauce Labs
  5. Perfecto

We have utilized AWS Device Farm for various reasons like easy to setup, test execution reliability, range of available devices etc.

Introduction of AWS Device Farm & integration with Appium

Device Farm is an app testing service hosted by Amazon Web Services (AWS) that provides you platform to test and interact with your iOS, Android and Web Applications on real mobile devices and tablets. Device farm can be utilized mainly two ways:

  1. Automated Testing of app using testing frameworks.
  2. Remote access of device for real time interaction.

Automated tests written with Appium needs to be uploaded on AWS device farm. Once the upload and integration is successfully done, testing is automatically performed in parallel on multiple selected devices. Post execution a test report containing high-level results, screen-shots and low-level logs is generated.

AWS Device Farm currently supports for following Appium test types (Android, iOS & Web Apps):

  • Appium Java JUnit
  • Appium Java TestNG
  • Appium Python

Steps to integrate your Appium Test with AWS Device Farm
Here we will look at setup of Appium Java TestNG on AWS device farm. Below are the prerequisites before getting started with the integration:

  • Appium Java TestNG Project
  • AWS Device Farm User Account
  • Eclipse IDE + Maven
  • Appium (currently device farm supports 1.4.16)

Before uploading your Appium Java TestNG project to device farm, it should be converted into a package.zip file. This package should contain all of test’s dependencies. Below are the steps to meets these requirements during package stage of Maven build.

  1. Modify pom.xml to set packaging as JAR file:

<groupId>KA_Appium_POC</groupId>
<artifactId>KA_Appium_POC</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

  1. Modify pom.xml to use maven-jar-plugin to build your tests into a JAR file:
The following plugin will build your test source code (anything in the src/test directory) into a JAR file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <goals>
                <goal>test-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

  1. Modify pom.xml to use maven-dependency-plugin to build dependencies as JAR files.
The following plugin will copy your dependencies into the dependency-jars directory:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.10</version>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
                <configuration>               
                <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

  1. Save the following XML assembly to src/main/assembly/zip.xml
The following XML is an assembly definition that, when configured, instructs Maven to build a .zip file containing everything in the root of your build output directory and the dependency-jars directory:

<assembly
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
        http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>zip</id>
  <formats>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>./</outputDirectory>
      <includes>
        <include>*.jar</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>./</outputDirectory>
      <includes>
        <include>/dependency-jars/</include>
      </includes>
    </fileSet>
  </fileSets>
</assembly>

  1. Modify pom.xml to use maven-assembly-plugin to package tests and all dependencies into a single .zip file.
The following plugin uses the preceding assembly to create a .zip file named zip-with-dependencies in the build output directory every time mvn package is run:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.5.4</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <finalName>zip-with-dependencies</finalName>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptors>
                    <descriptor>src/main/assembly/zip.xml</descriptor>
                </descriptors>
            </configuration>
        </execution>
    </executions>
</plugin>

Uploading your Android Appium Java TestNG on AWS Device Farm

Below are the steps to upload your test on device farm console:

  1. Sign in to the Device Farm: https://console.aws.amazon.com/devicefarm.
  2. From the list of Projects, select the option where you can upload your tests.
Automation-Mobile-Testing-Exhibit-1
  1. Select “Create a new run” button.
Automation-Mobile-Testing-Exhibit-2
  1. From “Choose Your Application”, choose Upload.
Automation-Mobile-Testing-Exhibit-3
  1. Browse and open your application having .apk format.
Automation-Mobile-Testing-Exhibit-3
  1. On the Configure a test page, choose Appium Java TestNG, and then choose Upload.
Automation-Mobile-Testing-Exhibit-5
  1. If your package is uploaded successfully, you will be asked to select devices from device pool.
Automation-Mobile-Testing-Exhibit-6
  1. Next and last step is to review your test and initiate the Run.
Automation-Mobile-Testing-Exhibit-7
  1. After completion of execution, AWS Device Farm will give execution status containing a test report with high-level results, screen-shots and low-level logs.
Automation-Mobile-Testing-Exhibit-8

Takeaway:
Mobile App testing with Appium on AWS makes it easier to control the test environment and predict the outcomes via cloud computing. It allows complete access and control to large device clouds or server farms that feature humongous real mobile devices. Which in turn, will emulate and simulate test conditions and parameters to meet their objective and report any discrepancies. This negates the need to use own devices and adapt them to meet the application testing. Certainly, testing apps via AWS clouds on Appium will dominate the application testing in the future.

Watch our webinar:

Mobile Automation on AWS Device Farm using Appium

Blog Written By Rishil Bhatt, Senior QA Consultant, Anblicks

Cloud Cost Management Logo Web
Hadoop to Snowflake New Web
capptixAI-case-study
lendingAI-logo_opt
CustomerAI_Logo_700x300 copy
sales-ai-logo-500x200