How to Set Up an Environment for Android Apps Automation Testing on Linux

788

In this day and age mobile app development has become decidedly mainstream. As more and more people do everything from ordering food to paying their bills from their smartphones, the need for creating great applications will not go away anytime soon. However, app development can be a long and arduous process, one that’s subject to all kinds of human errors. To that end, it’s now become fairly commonplace to automate certain test scenarios in order to avoid mistakes and decrease time consumption.

If you’re a budding programmer looking to make the most out of automated tests, you’ll need the following tools for starters:

1. A testing framework that comes with a set of APIs to build UI tests (we recommend Appium)

2. An Android simulator (Genymotion works best)

3. An integrated development environment (IDE)

Once these are in place, we recommend setting up Appium to begin the automation process. Appium uses WebDriver and DesiredCapabilities, and you will need npm, the default package manager for Javascript runtime environment Node.js in order to install it. Installing npm on Linux can be done using brew, the OS package manager for Linux, and requires a bit of coding:

1. First of all – required dependencies. Paste the command below to terminal:

sudo apt-get install build-essential curl git python-setuptools ruby

2. Now install linux brew with ruby. Paste the command below to terminal:

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)”

3. Add to your .bashrc or .zshrc:

export PATH=”$HOME/.linuxbrew/bin:$PATH”

export MANPATH=”$HOME/.linuxbrew/share/man:$MANPATH”

export INFOPATH=”$HOME/.linuxbrew/share/info:$INFOPATH”`

4. Now we can install node using linux brew:

brew update

brew install node

brew link node

This procedure will take around 25 minutes. After the successful node installation you can install Appium through: npm install -g appium

Now it’s time to download and set-up Android SDK. This one’s easier, as all you need to do is follow instructions step-by-step and select the necessary packages for your chosen Android versions.

As far as Android Emulators go, we prefer using Genymotion. It’s fast and easy to use and offers a whole lot of functionalities, including GPS support and real-time Wi-Fi connections. In order to get it up and running, you’ll first need to install Virtualbox via the Ubuntu Software Center on your workstation. Then download Genymotion and run the following commands:

chmod a+x ./genymotion-2.7.2-linux_x64

 

./genymotion-2.7.2-linux_x64

 

You’ll need a virtual device user ID and password, both of which can be obtained by registering with the Genymotion website. After that, just click start and you’re good to go.

Now it’s time to add an IDE into the mix. If you use Maven be sure to add Selenium, TestNG and Appium to your dependencies. Be sure to also create a folder where your .apk file will be stored.

Finally, for analysis of the application’s UI you should use UIAutomatorviewer. It’s a part of the Android Studio you previously set up and allows you to inspect the UI of an application and examine things like layout hierarchy and the properties associated with the application’s controls. There are many advantages to using UIAutomatorviewer, including its independence of screen resolution and its ability to use external buttons.

That concludes our brief guide on how to set-up an environment for automating Android application testing on Linux. Keep in mind that any app worth its salt needs to be properly tested before hitting the market if it has any chance of competing in the ridiculously crowded app landscape of today, so implementing a successful automation strategy may save you lots of time and money in the process.