Calabash Cucumber for iOS - Required Tools
Calabash library and framework
Cucumber tool - To execute the feature
Gherkin – to write steps [Behavior driven, domain specific language]
Jenkins/maven for Reports
Ruby gems – All of the above require ruby, as they are written in ruby
Calabash iOS
Automation and test library for iOS
Behavior Driven Development for testing
Consists of 2 parts
Client library : written in Ruby
Calabash.framework: server framework written in objective C ( have to be linked to our test build)
Calabash Architecture
The server framework will start an HTTP server inside our app that listens for requests from the client library (Courtesy: Lesspainful.com)
Accessibility Labels
One of the ways calabash interacts with the UI elements in your app via accessibility labels.
That’s how it knows which button to tap when a command like Then I touch "reply“ is issued
Enable this from Settings->General->Accessibility->Accessibility Inspector (ON)
Writing a test
You’ll need two files
xxx.feature (steps are written using Gherkin)
Xxx.rb (steps are implemented using ruby)
There are a lot of predefined steps that come when you install calabash cucumber iOS
Custom steps can be written using ruby
Sample Feature File
Feature: Send Email Logs from Workplace
As an iOS tester
I want to go to My device tab
so I can send email logs
Scenario: Send Email logs
Given I am on my device
Then I touch “Email Logs”
Sample Step definition
Given /^I am on my device$/ do
if view_with_mark_exists(“Email Logs”)
macro ‘I should see a “Email Logs” button’
end
end
Running on simulator
Bind your app with calabash.framework and create a testbuild and launch it in simulator
The following will be there on Xcode console
Creating the server:
Started LPHTTP server on port 37265
Bonjour Service Published: domain(local.) type(_http._tcp.) name(Calabash Server)
Command to run on simulator
$DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber features/send_email.feature
Run Group of tests
Tag the scenarios with @
@negative_test
Scenario: Send email button pushed down
DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber --tags @negative_test
Exclude some tests by ~
DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber --tags ~@negative_test
Running it on device
The device and the machines that runs xcode has to be on the same wifi.
DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber features/send_email.feature DEVICE_ENDPOINT=http://your.device.ip.address:37265
Calabash-ios Console
You can get into the interactive ruby console
$calabash-ios console
Another way to find out UI elements is thro console.
$query "tableViewCell index:0“
This can be used to write custom step definitions.
Record and Playback from Calabash-ios Console
Record and playback
$record_begin
$Record_end “xxx”
Creates a .base64 file with the above name
$playback “xxx”
Download links
https://github.com/calabash/calabash-ios
Calabash library and framework
Cucumber tool - To execute the feature
Gherkin – to write steps [Behavior driven, domain specific language]
Jenkins/maven for Reports
Ruby gems – All of the above require ruby, as they are written in ruby
Calabash iOS
Automation and test library for iOS
Behavior Driven Development for testing
Consists of 2 parts
Client library : written in Ruby
Calabash.framework: server framework written in objective C ( have to be linked to our test build)
Calabash Architecture
The server framework will start an HTTP server inside our app that listens for requests from the client library (Courtesy: Lesspainful.com)
Accessibility Labels
One of the ways calabash interacts with the UI elements in your app via accessibility labels.
That’s how it knows which button to tap when a command like Then I touch "reply“ is issued
Enable this from Settings->General->Accessibility->Accessibility Inspector (ON)
Writing a test
You’ll need two files
xxx.feature (steps are written using Gherkin)
Xxx.rb (steps are implemented using ruby)
There are a lot of predefined steps that come when you install calabash cucumber iOS
Custom steps can be written using ruby
Sample Feature File
Feature: Send Email Logs from Workplace
As an iOS tester
I want to go to My device tab
so I can send email logs
Scenario: Send Email logs
Given I am on my device
Then I touch “Email Logs”
Sample Step definition
Given /^I am on my device$/ do
if view_with_mark_exists(“Email Logs”)
macro ‘I should see a “Email Logs” button’
end
end
Running on simulator
Bind your app with calabash.framework and create a testbuild and launch it in simulator
The following will be there on Xcode console
Creating the server:
Started LPHTTP server on port 37265
Bonjour Service Published: domain(local.) type(_http._tcp.) name(Calabash Server)
Command to run on simulator
$DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber features/send_email.feature
Run Group of tests
Tag the scenarios with @
@negative_test
Scenario: Send email button pushed down
DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber --tags @negative_test
Exclude some tests by ~
DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber --tags ~@negative_test
Running it on device
The device and the machines that runs xcode has to be on the same wifi.
DEVICE=iphone OS=ios5 NO_LAUNCH=1 cucumber features/send_email.feature DEVICE_ENDPOINT=http://your.device.ip.address:37265
Calabash-ios Console
You can get into the interactive ruby console
$calabash-ios console
Another way to find out UI elements is thro console.
$query "tableViewCell index:0“
This can be used to write custom step definitions.
Record and Playback from Calabash-ios Console
Record and playback
$record_begin
$Record_end “xxx”
Creates a .base64 file with the above name
$playback “xxx”
Download links
https://github.com/calabash/calabash-ios