Skip to content

How To Set Up Calabash Android On Windows

  • by

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 .feature file.

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: \sdk

Step 3: Set Variable Name: JAVA_HOME Variable Value: \jdk1.8.0_11\

Step 4: Set Variable Name: JRE_HOME Variable Value: \jdk1.8.0_11\

Values should be the name of corresponding SDK directories

android_home

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/

(https://developer.xamarin.com/guides/testcloud/calabash/configuring/windows/installing-ruby/)

Please note that do not forget to check “Add Ruby executables to your path”

add_Exicutables

After that please make sure that ruby path is set in environment variable list

ruby_home

Step 6: Installing the Calabash Gems on Microsoft Windows

(https://developer.xamarin.com/guides/testcloud/calabash/configuring/windows/installing-gems/)

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:

Folder Structure

features
|_support
| |_app_installation_hooks.rb
| |_app_life_cycle_hooks.rb
| |_env.rb
| |_hooks.rb
|_step_definitions
| |_calabash_steps.rb
|_my_first.feature

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 .feature extension.

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.

Example

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	

Running test

To run your test:

calabash-android run
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

On device

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 🙂

Leave a Reply

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