Calabash – Getting Setup

I’ve always been quite a fan of using the recommended technologies when developing in different platforms. In iOS you learn Objective-C and you use Java for Android.

By using the recommended technologies you can usually get more support and understanding of what you’re doing. The more abstract your development becomes, the more difficult things can become. You find yourself in a situation of ‘I know exactly what my JavaScript should look like, but I have no idea how to get Script# to take my C# and spit out the right thing.

My feelings aside, sometimes it’s hard to argue with the “write once – deploy everywhere” mindset that so many have. So after some time and many discussions at work, we decided to use Calabash for our automated acceptance testing.

At work, we have an Android and an iOS product, so in this tutorial, we’ll set up both Android and iOS versions of Calabash, but once they’re both set up we’ll focus on Android testing first.

Edit: Since this post, I’ve learned that Calabash in iOS is almost unusable. I spent hours trying to get everything set up, but nothing I did worked quite right. Testing with Frank is a better solution for iOS. I’m working on a post about it (update: here’s a few things I’ve written about it, I just haven’t written a setup post for it – 1, 2).

The repositories can be found at:
https://github.com/calabash/calabash-android
https://github.com/calabash/calabash-ios

In order to actually do anything with calabash for Android, you’ll need to have access to the apk. If you don’t have access to it, and you don’t have a way to get access to it, there’s not really anything calabash can do for you. The Android version of Calabash installs it’s own package alongside the apk. The package it installs alongside the apk is what makes everything work. If you don’t have the apk, Calabash can’t set up the required dependents and you won’t be able to do anything.

The installation require Ruby 1.8.7 or higher. Unfortunately for some, I’m on a Mac so I won’t be of too much use to someone in Windows. But if you happen to be on Windows you can go to RubyInstaller.org to install ruby.

On a Mac, you’ll need to install Xcode from the Mac App Store. Once you have Xcode installed, you’ll need to open it up and install the command line tools. It should be at Xcode -> Preferences… -> Downloads.

Open up terminal and check that Ruby is there

We’ll also need the Android SDK. Head over to http://developer.android.com/sdk/index.html and pick them up. Personally I can’t stand using Eclipse. I have IntelliJ 12 and 13 (Community Edition) installed alongside Android Studio. With 3 IDE’s installed for Android development I installed the Android SDK as a stand-alone and deleted the embedded version in Android Studio. That way i have 1 SDK that is shared by all my IDE’s. If you want to do something similar, or you just want the SDK without the bloat of an IDE (QA test engineers for example) you can just click the link for “USE AN EXISTING IDE.”

Now that you’ve got the Android SDK, unzip where ever you want to keep it. Once you’ve done that, set up an environment variable for it. Open up ~/.bash_profile and add the following:

The first line sets up your ANDROID_HOME and the second line puts it in your path. you can check that this all worked by opening up terminal and typing adb devices.  You should also open up the Android SDK manager and install the latest build tools, emulator and anything else that it tries to get you to install

Another requirement is that ant must be on your path. For Mac os, once you’ve got your Xcode command line tools installed, it is already in your path so we won’t worry about steps for that.

Now that you meet the minimum requirements, you can install the Ruby gems you need. The commands will install some tools in your path so it doesn’t matter what directory you’re in, the results are the same.

These will both take a while to run. The install guide in the calabash-android GitHub project doesn’t provide any troubleshooting other than making sure you have the Xcode command line tools installed, so if the command doesn’t work and you have the tools installed you’re basically out of luck unless you can find an answer in Google or StackExchange etc. Update, if you get an error for Nokogiri, I do have a post that may help.

For everything to work right with calabash, you’ll need to make sure you have an Android development certificate. If you have ever built an Android application in an IDE, you can skip this part. IDE’s handle this on their own.

Open up the terminal and do the following

Calabash is now set up, so we’ll be able to start the fun stuff.

Head over to my post on getting into interactive mode to learn how to get started with interactive mode.

Leave a Comment

Your email address will not be published. Required fields are marked *