Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Calabash for iPhone apps


Published on

Understand and start work with calabash automated testing for iPhone apps

  • Be the first to comment

Calabash for iPhone apps

  1. 1. CALABASH For iPhone Apps By Chathura Palihakkara.
  2. 2. ROAD MAP • What is calabash • Main Components • Simple demo • Q&A • Getting started
  3. 3. WHAT IS CALABASH • Framework that enables you to write and execute automated acceptance tests for mobile apps. • Supporting cross-platform, Android and iOS native apps. • Free and open source. • Behavior-driven developing(BDD) with natural language. • Supports continuous integration. • By Karl Krukow and Joshua Moody
  4. 4. CALABASH ARCHITECTURE Step Definitions Step Definitions Step Definitions Feature Files Feature Files Feature Files Dev PC / Build server Calabash iOS Client JVM Ruby Gems Device / Simulator HTTP Calabash HTTP server
  5. 5. MAIN COMPONENTS • Feature files • Contains the sequential actions for the test. • Step definitions • Contains the steps definitions written in Ruby. • Support files • Contains project configurations (Build path).
  6. 6. FEATURE FILES FEATURE • • • • Abstract Description of the Test Case <name of feature> In order to <meet some goal> As a <type of role> I want <a feature> SCENARIO • • • Gestures Touches or gestures (e.g., tap, swipe and rotate). Assertions There should be a "Login" button or I should see a Alert message. Screenshots Screen dump the current view on the current device model Note: There is no place like HOME. Always start from HOME and come back to it.
  7. 7. FEATURE FILES Feature: Validate user login As a registered user In order to see user details I want be able to sign in to the App with correct credentials Scenario: User logged in and see user details Given I go to the Home Screen When I touch “My account” button Then I wait to see Login Screen Then I enter "my_username" into text field number 1 Then I wait Then I enter "my_password" into text field number 2 Then I wait when I touch "Sign In" button Then I wait to see My account screen Then I should see "my_username” label Then I should see ”072-3354020” label when I touch "Sign Out" button Then I wait to see Home Screen Then I finish the test
  8. 8. STEP DEFINITIONS Then I touch the ”Sign In" button Then /^I touch the "([^"]*)" button$/ do |name| If elements_exist( ["button marked:'#{name}'”]) touch("button marked:'#{name}'") sleep(STEP_PAUSE) else screenshot_and_raise "'#{name}' Button isnt exsist.” end end
  9. 9. UI QUERY • How you can find the current visible components in the iPhone/ simulator screen. • Open ruby console to write UI Query • In mac terminal type “calabash-ios console” Ex: 1. query("view:'UIButton'",:accessibilityLabel) [ [0] "icon rewards new", [1] "icon my receipts new", [2] "icon my account", [3] "icon order@2x", [4] "icon check in" ] 2. element_exists("button marked:'Delivery'”) false
  10. 10. STEP DEFINITIONS COMBINED STEPS Then /^I delete order from checkout screen$/ do steps %{ Then I should see a "Delete" button Then I touch the "Delete" button after it appears Then I wait for 1 seconds Then I see an alert with "Are you sure you want to delete this order?" text Then I touch the "YES" button Then I wait for 1 seconds Then I go Home Screen } end
  11. 11. REPORTS Several types of detailed calabash repots
  12. 12. DEMO
  13. 13. USER LOG-IN WITH CORRECT CREDENTIALS Feature: User log-in with correct credentials In order to use LeapsetApp As a Registerd user I want to be able to successfully log-in file_name: demo_login.feature Test Case: IPA-21 Scenario: User log-in with correct credentials Given I start from the Home Screen When I touch MyAccount button Then I should see login screen Then I sign In with name "" pass "chathura123" And I wait until UIActivityIndicator is gone Then I should see myAccount screen Then I see the text "" Then I see the text "Take rode, My Street, Owk city, AL, 55555” When I touch Sign Out button Then I should see home screen
  14. 14. DIRECTORY STRUCTURE Project root Features folder Step_definition folder
  15. 15. RUN Use Terminal and go to Project directory Launch the app in the simulator and come to the home page Then run the command Now it runs the test on the simulator Create a result as a HTML page in side the root directory
  16. 16. RESULT
  17. 17. Q&A
  18. 18. GETTING STARTED • Setup calabash environment • Set up iOS project and configure it for calabash • Run calabash tests for iPhone app • Start writing test features Set up
  19. 19. PREREQUISITES 1. Macintosh PC. 2. Xcode 4.x.x or above Installed. 3. Xcode command line tools Installed. 4. iPhone SDK 6.0 and iPhone simulator 6.0 installed. 5. JAVA JRE 1.6 or above installed 6. Ruby v1.9 or above installed 7. Stable Internet connection.
  20. 20. CONFIGURE LEAPSET iPhone CONSUMER APP • Checkout project source using terminal $ svn co svn+ssh://checkout url • Open project using Xcode make sure the app run on the iPhone simulator • Install calabash-cucumber ruby gem using terminal $ sudo gem install calabash-cucumber • Select Leapset project in XCode and select your product target for your app. • Right click (or two-finger tap) your target and select "Duplicate target” Select "Duplicate only" (not transition to iPad)
  21. 21. Configure iPhone App • Rename your new target from ”ProjectName" to "ProjectName-cal”. • From the menu select Scheme and select manage schemes Rename the new scheme from "ProjectName copy" to "ProjectName-cal”. • From the menu select Scheme and select Edit schemes set build configurations to Staging on ProjectName-cal target.(if you have “Staging” scheme else select your scheme correctly).
  22. 22. Configure iPhone App • Download the latest version of calabash-ios at • Unzip the file and Drag calabash.framework folder into you project's Frameworks folder in xcode navigation pane. • Make sure that (i)Copy items into destination group's folder (if needed) is checked (ii) only your "-cal " target is checked in Add to targets
  23. 23. Configure iPhone App You should see like this.
  24. 24. Configure iPhone App • Target Build Settings • • • Click on your project and select your new ”ProjectName-cal" target. Select "Build Settings" Ensure that "All" and not "Basic" settings are selected in "build settings”. Find "Product name" (you can type "Product name" in the search field). Set the Product name to Productname-cal
  25. 25. Configure iPhone App • Find "Valid Architectures" in Build Settings and Add "i386" for the new target.
  26. 26. Configure iPhone App Find "Other Linker Flags" in Build Settings and set flags (i)-lxml2 $(inherited) (ii)-force_load "$(SRCROOT)/calabash.framework/calabash" (iii)-lstdc++
  27. 27. Configure iPhone App • In Xcode select your ”ProjectName-cal" scheme and then run you app on 6.0 simulator once. • Allow location services by pressing "OK" for the location services alert if present.
  28. 28. Configure iPhone App • Open Terminal and direct it to the project root $ cd /User/Desktop/release-1.081/ProjectName • Generate features folder in side the project root using terminal Type • • • $ calabash-ios gen Press "Return(Enter)" again to confirm the action This will create the default folder structure for calabash Features directory created
  29. 29. ADD CURRENT TEST TO THE PROJECT • In the project root add a new calabash feature file in to “features" folder and Launch the app in simulator • Run the tests using command (since app is already launch in the simulator and running) • • NO_LAUNCH=1 cucumber --format html --out result.html features/<file name>.feature You can get help form type cucumber –help • Open the result.html To see the results. • Remember feature files ended with extinction “.feature” • Install eclipse and import and open “features” folder as a project to write new test cases or Net beans have more support with a plugin.
  30. 30. Q&A