2. 4
1. Calabash is an automated testing technology for Android and iOS native
and hybrid applications.
2. Calabash is a free opensource project, developedand maintained by
Xamarin.
Introducing Calabash
Calabash consists of two libraries calabash-android and calabash-ios.
Calabash-iOS and Calabash-Android are the underlying low-level libraries
that empowerthe 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.
Example:
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 specificationof a use case of the app.
Overview: How It Works
Calabash iOS consists 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
3. 4
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) steps 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
4. 4
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 forboth
Android and iOS. The platform or app differencescan 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 Cucumbertechnologygives us this. A Cucumberfeature
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 technologythat is as authentic as
possible. Testmust 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.
Installation
Prerequisites
You need to have Ruby installed. This is installed by default on
MacOSX.
5. 4
To Verify, type “$ ruby -v” in terminal. It should be at least ‘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. directorycontaining .xcodeproj file)
2. Install calabash-
cucumber gem (this make take
some time because of
dependencies)
$ gem install
calabash- cucumber
Note: you may need to run,
$ sudo gem install calabash-cucumber
if you see ERROR:While executing gem ... (Gem::FilePermissionError)).
3. You check, whether a gem is installed or not. By running
6. 4
$ gem list
4. Setup your project for Calabash-iOS.
$ calabash-iossetup
(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 folderfor your tests
$ calabash-iosgen
(You should be able to see following response)
7. 4
6. In Xcode, build your
project using the -cal
scheme
6. 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. 4
7. Running Calabash Console
$ calabash-iosconsole
(This will help you
to run the calabash
target project file, to test in
the simulator.)
Type: irb(main):001:0> start_test_server_in_background (to start
the simulator )
Updating
Updating 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-iosdownload
Finally, deep clean (Shift + Option + Command + K) and rebuild your project.
Source: