Environment Setup for Calabash Testing

In order to begin writing automated test suites with calabash, you will need to set up your dev environment.

This is an exciting and necessary step in achieving a productive scripting work flow. So I thought I would write this guide to lower the barrier to entry and help you get up and running sooner.

Both calabash-ios and calabash-android were originially written as Ruby libraries. Therefore, I will be showing you how to set it up using Ruby and Mac OSX.

Let’s get started:

  1. Install Homebrew (The missing package manager for OS X)

    • From the shell run:

      • ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

  2. Install RVM (Ruby Version Manager)

    • Currently, I am using the following version: ruby 2.0.0p247

    • In order to replicate my environment, run this from the shell:

      • rvm install 2.0.0-p247
      • rvm --default use 2.0.0-p247

  3. Install Xcode, the Command Line Tools, and iOS Simulators

    • Open up the Mac App Store and search for Xcode.

    • Install Xcode from there and login using your Apple Developer login/password.

    • Once the application is installed, open it up and download the Command Line Tools and iOS Simulators.

      • They should be located within Xcode Preferences –> Downloads

        • If for some reason they are not available there, search for them here.

  4. Install Required Gems (The Ruby Package Management System)

    • From the shell run:

      • gem install 'bundler'
      • gem install 'calabash-cucumber'
      • gem install 'calabash-android'
      • gem install 'pry'

  5. Install the Android Debug Bridge (adb)

    • Download the Android SDK

    • Unzip the file and rename the folder to “ android-sdk

    • Nest the folder in any directory you like. I suggest /Users/YOURUSERNAME/Development

    • Add the folder location to your $PATH

      • From the shell: cd then open -a TextEdit .bash_profile

      • Add this: export PATH="/Users/YOURUSERNAME/Development/android-sdk/platform-tools/":$PATH

    • Open a new shell window and enter the command adb

    • If you see a list of adb help commands, you’re all set!

  6. Generate an Android debug.keystore

    • If debug.keystore is missing, it be recreated in ANDROID_HOME with the following command:

      keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"

  7. Download Genymotion

    • This is an alternative Android emulator.

  8. Download Oracle VirtualBox

    • This works in conjunction with Genymotion to simulate Android devices.

  9. Enable the Google Playstore on all your virtual device simulators

    • If you are not signed in with an account on the Google Playstore on each device, you will not be able to run calabash automated scripts in the simulator.

    • Here is an excellent guide from Stack Overflow detailing how to do this.

    • I consistently use the Galaxy Nexus 4.3 API 18 when authoring scripts locally. Of course, feel free to choose any device or version level you want.

…and that’s it!
Assuming everything went well, you are now ready to begin writing calabash powered, automated test suites. Enjoy!