Quality to me is

"Synergistic phenomena experienced by the user(s) when the product or a service satisfies the requirements, achieves business goals, exceeds expectations, is incredibly usable with real-time servicing & updates, optimal performance and cost effective"

Friday, March 22, 2013

Calabash Cucumber for iOS

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

2 comments:

Rexy said...

Thank you very much for this detailed view on iOS automation.
i would like to know about UIAutomation tool from apple also is selenium can be used for mobile automation.

Unknown said...

Thanks Rexy,
Will post a quick startup guide to get started on UIAutomation in a couple of days.
Yes, you can use selenium for mobile app automation