iOS Automated Testing with Calabash: Tips and Tricks

24
iOS Automated Testing with Calabash: Tips and Tricks Moncef Belyamani @monfresh Mobile Testing Summit / November 1, 2012 / San Francisco

description

 

Transcript of iOS Automated Testing with Calabash: Tips and Tricks

Page 1: iOS Automated Testing with Calabash: Tips and Tricks

iOS Automated Testing with Calabash: Tips and Tricks

Moncef Belyamani@monfresh

Mobile Testing Summit / November 1, 2012 / San Francisco

Page 2: iOS Automated Testing with Calabash: Tips and Tricks
Page 5: iOS Automated Testing with Calabash: Tips and Tricks

iPad Apps

iPhone Apps

Page 6: iOS Automated Testing with Calabash: Tips and Tricks

AUTOMATION TOOL CHECKLIST

• Easy to set up and maintain

• Updated regularly

• Well-documented

• Supports iOS and Android

• Runs on devices untethered

• Readable tests

Page 8: iOS Automated Testing with Calabash: Tips and Tricks

AND THE WINNER IS...

Page 11: iOS Automated Testing with Calabash: Tips and Tricks

CALABASH TEST

FEATURE FILE + STEP DEFINITION

Page 12: iOS Automated Testing with Calabash: Tips and Tricks

FEATURE EXAMPLE

Feature: Comments In order to contribute to the discussion As a Hacker News reader I want to be able to add a comment

Scenario: User not logged in Given I am not logged in When I go to comment on a submission Then I should be prompted to log in

Page 13: iOS Automated Testing with Calabash: Tips and Tricks

DON’T DO THIS

Scenario: User logged in, but cancels comment form Given the app is running

When I touch "Profile" Then I wait to see "Login" Then I fill in “Username” with "my_username" Then I touch “Password” Then I fill in “Password” with "my_password" Then I touch done Then I wait to see "Logout" Then I touch "Home" Then I touch list item number 1 Then I touch "reply" Then I touch "Cancel" Then I should see "Submission"

Page 14: iOS Automated Testing with Calabash: Tips and Tricks

DO THIS

Scenario: User logged in, but cancels comment form Given I am logged in as “username” When I go to comment on a submission But I cancel the comment form Then I should see the submission And a comment from "username" should not appear

Page 15: iOS Automated Testing with Calabash: Tips and Tricks

STEP DEFINITION

Given /^I am logged in as "([^\"]*)"$/ do |username| macro 'I touch "Profile"' if element_exists("button marked:'Logout'") sleep(1) else macro %Q[I fill in “Username” with "#{username}"] macro 'I touch “Password”' macro 'I fill in “Password” with "my_password"' macro 'I touch done' macro 'I wait to see "Logout"' end end

Page 16: iOS Automated Testing with Calabash: Tips and Tricks

UPDATING IS EASY, BUT...

• gem update calabash-cucumber

• calabash-ios download (not with SVN)

• curl http://localhost:37265/version (to verify framework is up to date)

• May need to “Reset Content and Settings” in Simulator

•When new files are added, update Target Membership

Page 17: iOS Automated Testing with Calabash: Tips and Tricks
Page 18: iOS Automated Testing with Calabash: Tips and Tricks

KEEP IN MIND

Swiping depends on device orientation

Can only touch visible items

Page 19: iOS Automated Testing with Calabash: Tips and Tricks

TIPS & TRICKSUse .bash_profile aliases self.myButton.accessibilityElementsHidden = YES;

Use console to experiment and “query” to find elements

Participate in the Google Group

Get commit notifications with GitHub for Mac

Page 20: iOS Automated Testing with Calabash: Tips and Tricks

RECOMMENDATIONS

• Full-time Automation Engineer

•Work with Dev to make apps accessible

• Continuous Integration

• Contribute fixes and custom steps

Page 23: iOS Automated Testing with Calabash: Tips and Tricks

QUESTIONS?

Page 24: iOS Automated Testing with Calabash: Tips and Tricks

THANK YOU!