What is Calabash?
Calabash is a cross-platform automated testing technology for Android and iOS (native/hybrid) apps. Calabash is a free open source project, developed and maintained by Xamarin.
How does it do?
Like every other automation testing tool calabash has a test server and test script. This test script will perform on server and return the result. A test script is written as
scenarios and it has
test cases under it. These test cases will decide which action should be performed on application. The script file is saved as
Steps To Setup Calabash
I will explain the entire set up as multiple steps. These are as follows,
Step 1: Install Windows PowerShell
Step 2: Set Variable Name: ANDROID_HOME Variable Value:
Step 3: Set Variable Name: JAVA_HOME Variable Value:
Step 4: Set Variable Name: JRE_HOME Variable Value:
Values should be the name of corresponding SDK directories
In order to create or run Calabash test scripts on Windows, it is necessary to install the Calabash client libraries that allow a Calabash test script to interact with the application being tested. These libraries are distributed as Ruby Gems. A Ruby Gem is a self-contained package that is the standard format for distributing Ruby programs and libraries. Gems are typically hosted and distributed at
RubyGems.org and are installed via the gem command line tool.
These libraries are available via the following Ruby gems:
calabash-android – these are the API’s for tests targeting Android applications and the command line utilities for running the tests locally.
xamarin-test-cloud – this gem contains the command line utility test-cloud which is necessary to submit mobile applications and tests to Xamarin Test Cloud.
Step 5: Install Ruby from here http://rubyinstaller.org/downloads/
Please note that do not forget to check “Add Ruby executables to your path”
After that please make sure that ruby path is set in environment variable list
Step 6: Installing the Calabash Gems on Microsoft Windows
This above step will install calabash-android into your machine.
Make sure there is no errors when you install Calabash Gems.
Step 7: Create Calabash Tests
You can create Calabash Tests easily using predefined steps.
(please refer this link https://github.com/calabash/calabash-ios/wiki/02-Predefined-steps)
Please see a skeleton of test case folder ,
Generate a Cucumber skeleton
To get started with calabash it might be a good idea to run calabash-android gen. It will create a Cucumber skeleton in the current folder like this:
In this skeleton you find all the predefined steps that comes with calabash. Try to take a look my_first.feature and change it to fit your app.
Writing a test
The Cucumber features goes in the features library and should have the
You can start out by looking at features/my_first.feature. You can extend this feature or make your own using some of the predefined steps that comes with Calabash.
Feature: Capture And Upload Feature Scenario: Taking some pics and upload When I press view with id "btn_enter" Then I should see text containing "HELLO ANDROID" Then I wait for 3 seconds Then I take a screenshot
To run your test:
Calabash-android will install an instrumentation along with your app when executing the app. We call this instrumentation for “test server”. The “test server” has special permission that allows it to interact very closely with your app during test. Every Time you test a new binary or use an upgraded version of calabash a new test server will be build. The test server is an instrumentation that will run along with your app on the device to execute the test.
Step 8: Change current working directory to project folder
Step 9: Run calabash-android gem
Step 10: Replace content of feature file with already created tests
Step 11: Check USB debugging on device
Step 12: Connect device to computer
Step 13: run calabash-android resign
This step will sign your apk. calabash-android required your apk to be signed. Once an apk is signed no need to sign it again. After this command is executed you can go to the next step.
Step 11: run calabash-android run
This is the final step. When this is executed your tests will begin to perform on the apk. After all steps are performed you will get message of either success of failure.
Please ask me if you have any doubts on this topic.
Thanks And Good luck 🙂