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:
- 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)"
- From the shell run:
- 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
- Currently, I am using the following version:
- 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.
- If for some reason they are not available there, search for them here.
- They should be located within Xcode Preferences –> Downloads
- Open up the Mac App Store and search for Xcode.
- 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'
- From the shell run:
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
thenopen -a TextEdit .bash_profile
- Add this:
export PATH="/Users/YOURUSERNAME/Development/android-sdk/platform-tools/":$PATH
- From the shell:
- Open a new shell window and enter the command
adb
- If you see a list of adb help commands, you’re all set!
- Download the Android SDK
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"
- If debug.keystore is missing, it be recreated in
- Download Genymotion
- This is an alternative Android emulator.
- This is an alternative Android emulator.
- Download Oracle VirtualBox
- This works in conjunction with Genymotion to simulate Android devices.
- This works in conjunction with Genymotion to simulate Android devices.
- 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.
- 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.
…and that’s it!
Assuming everything went well, you are now ready to begin writing calabash powered, automated test suites. Enjoy!