blog

Let's talk about testing

It’s time for a follow-up to my previous post on pioneering with Appium a month ago. In this post I assembled the required software to do automated testing for Android on Windows. In this post I’ll describe the same process for Mac OSx.

So, we’re building a Ruby-based Appium set-up for Mac OSx intended for testing Android applications on a real device. This guide is aimed at people who are fairly new to mobile test automation. It describes all the software needed and how to install it.

OSx
For the aspiring test automation engineer this could be the biggest challenge. Having no licensed OSx machine (virtual or physical) means not being able to use Appium for iPhone at all. I tried to find workarounds to run Appium on iOS from my Windows machine.. but, there ain’t a workaround, trust me. Good thing that that this is a guide for OSx users. So for you, dear reader, this shouldn’t prove to be a problem. My set-up is using OSx Sierra.

Several versions of Xcode as installed on my Mac

Xcode
Appium utilises many Xcode features to communicate with your phone. Also, through Xcode, Appium gets the required authentication to address and control the application. A ton of security features are placed inside Xcode to make sure you are an actual licensed developer trying to push software to a registered device. At the time of writing this post xCode 9 has just been released. Since it’s fairly new I’ll stick with 8.3.3 for now.

Just download and install Xcode 8 from the website and launch it at least once to activate it. It is possible to run Xcode 8 and Xcode 9 on the same machine.

Ruby
Installing Ruby on OSx is quite different from Windows. You can actually download an installer from the site and run it, but we’re instead going to use the terminal for this. The reason? It’s easy! To be able to download Ruby using the terminal, we need the Ruby Version Manager or RVM. To get the Ruby Version Manager, simply type the following command in the terminal (commands for the terminal are written in italics):

source ~/.rvm/scripts/rvm

This will install RVM. We then need to activate it by typing the following command:

type rvm | head -n 1

The Ruby Version Manager can in its own turn install Ruby. Type the following command to install Ruby. I use an older version of Ruby for consistency with the Windows set-up:

rvm install ruby 2.3.3

Homebrew
If you’re using a Mac regularly, you’re probably familiar with Homebrew. This nifty tool provides you with all the software you need for doing techie stuff on OSx. It’s awesome and you’ll need it. Installing Homebrew is, like RVM, a piece of cake. Type the following command in the Terminal and Homebrew will install itself:

NodeJS, Apache Maven and Apache Ant
Like in my previous post we have a couple of software dependencies. NodeJS, Apache Maven and Apache Ant are libraries which Appium needs. With a little help from Homebrew we can install them easily. Type in the following commands, one line at a time:

brew install nodejs.org

brew install ant

brew install mvn

Android Software Development Kit
Blasphemy! The Android Software Develoment Kit or SDK to be installed on an Apple machine! Well, we aim to test on Android remember? We’ll get to iOS in a later post, but it isn’t our point of focus right now. To get Android applications to install from a Mac we need the Android SDK. To install this, we use Homebrew again. Type the following commands in the Terminal:

brew tap caskroom/cask

brew cask install android-sdk

The Android SDK is now installed but, as it is not common software for OSx, we still need to set the environment variables. First create an Android home variable using the following command:

export ANDROID_HOME = /usr/local/Caskroom/android-sdk

Then add the Tools and Platform-tools folders as separate paths:

export PATH = $ANDROID_HOME/platform-tools:$PATH

export PATH = $ANDROID_HOME/tools:$PATH

In the last step we need to add the changes to our current user profile. Use the following command to do so:

source ~/.bash_profile

Check if the paths have been set up correctly by printing the main Android location:

echo $ANDROID_HOME

Appium
We’ve finally arrived at the closing link in the chain (once more): Appium. We’re not downloading this software either – we’re getting it from GitHub this time. Type the following command in the Terminal to download the Appium repository to your system:

git clone git://github.com/appium/appium.git

The neccesary files are now present on your system but they still need to be installed. To do so, use the commands below. First open the folder where the files are stored:

cd appium

Then install Appium:

npm install

To start Appium, go to the installation folder and start the server:

cd appium

node .

Appium is now running in the terminal. It is also possible to download and install the software from the website instead. This way it is possible to get Appium server 1.4 with the integrated inspector. I have the terminal version of Appium for running script and the application for the inspector. Please set it up to your own preference.

That brings us to the end of the second part of the series. All software is in place, next time we’ll start using it. More posts about Appium development will follow soon. Stay tuned.