iOS Automated Testing With Calabash-Cucumber |



iOS Automated Testing With Calabash-Cucumber

February 5th, 2015 | Code

Introducing Calabash

Automation testing in mobile arena growing day by day in large scale, there are lot of open source projects are available in market to help the developers and QA team to face the problem of building a efficient,dynamic, robust tools and frameworks for mobile testing.

Calabash framework for iOS was first released in 2012. From there onwards it’s became a popular automation testing framework for mobile applications.Calabash consists of two libraries calabash-android and calabash-ios.

Calabash-iOS and Calabash-Android are the underlying low-level libraries that empower the Cucumber tool to run automated functional tests on Android and iOS phones and tablets as well as on simulators. These low-level libraries enable QA, business staff and developers to work at a high level by writing tests in a natural language using the terms and concepts of their business domain.

Getting Started With Calabash for iOS

  • Calabash is an automated testing technology for Android and iOS native and hybrid applications.
  • Calabash is a free open source project, developed and maintained by Xamarin.


  Feature: Rating a stand
    Scenario: Find and rate a stand from the list
      Given I am on the List
        Then I should see a "rating" button
        And I should not see "Dixie Burger & Gumbo Soup"
        And take picture
        //Feature File//

The above file example is called a feature file in Cucumber and Calabash. A feature file describes the intended behaviour of the app. You can think of a feature file as an executable test specification of a use case of the app.

Overview: How It Works

Calabash iOS consist of two parts: a client library written in Ruby, and calabash.framework, a server framework written in Objective-C. To use calabash you make a special test target in Xcode that links with calabash.framework. The application is otherwise unchanged. The server framework will start an HTTP server inside your app that listens for requests from the client library.

The cucumber tool executes your feature files which contain steps that are defined either in predefined or custom (user defined) step definitions. Custom steps are written using the API that the client library exposes. The API methods make HTTP requests to the server, which does things like finding components in the UI and taking actions on them.

Benefits Of Calabash

1. Uniform interface across platforms

Calabash provides us a single interface for specifying the behaviour of mobile apps across platforms. Many companies are creating the same app (or almost the same app) for both iOS and Android, and pay double costs when it comes to testing. With Calabash, you have the option of maintaining only one feature file per app use-case, even if you are developing for both Android and iOS. The platform or app differences can be factored out into so-called step definitions which are different per platform.

2. Cucumber

Cucumber gives us a high-level, domain-centric language for specification. The Cucumber technology gives us this. A Cucumber feature file can be written by QA, domain experts or developers. Developers or technical test staff can then write step definitions to realise the steps on each platform.

3. Authenticity

Calabash Provides a test automation technology that is as authentic as possible. Test must be able to run equally well on physical, non-jailbroken devices as on simulators.

4. Expressive power

Calabash gives as a expressive power to support complex gestures(Swipe, pinch,etc..).

5. Extensibility and Community

Calabash allows users to be able to extend Calabash itself, and to build an open source community that is enthusiastic about the technology.



You need to have Ruby installed. This is installed by default on MacOSX.

To verify, type in terminal.

$ ruby -v

Your machine should be installed with at least ruby ‘1.9’ or ‘2.0+’.

For automatic setup:

1. In a terminal, go to your iOS project

$ cd path-to-my-ios-project

(i.e. directory containing .xcodeproj file)

2. Install calabash-cucumber gem (this may take some time because of dependencies)

$ gem install calabash-cucumber

Note:You may need to run, if you see ERROR: While executing gem..(Gem::FilePermissionError)).

$ sudo gem install calabash-cucumber

3. You can check, whether a gem is installed or not. By running

$ gem list

4. Setup your project for Calabash-iOS.

$ calabash-ios setup

(It detects the Xcode and look for a project file .xcodeproj and creates a calabash framework target ( -cal ) inside the project.)

5. Generate a skeleton features folder for your tests

$ calabash-ios gen

(You should be able to see following response)

6. In Xcode, build your project using the -cal scheme

7. Run the generated test!

$ cucumber

If all goes well, you are now ready to write your first test.Start by editing the file features/my_first.feature.

8. Running Calabash Console

$ calabash-ios console

(This will help you to run the calabash target project file, to test in the simulator.)

Type the following command to start the simulator

irb(main):001:0> start_test_server_in_background


Calabash iOS is usually very simple. First install the latest calabash-cucumber gem.

$ gem install calabash-cucumber

Or, if you’re using bundler, run

$ bundle update calabash-cucumber

Then, in the directory that contains the calabash.framework run

$ calabash-ios download

Finally, deep clean (Shift + Option + Command + K) and rebuild your project.

Congratulations! your project is ready for iOS Calabash testing!

Submit a Comment

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