• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Calabash for iPhone apps
 

Calabash for iPhone apps

on

  • 744 views

Understand and start work with calabash automated testing for iPhone apps

Understand and start work with calabash automated testing for iPhone apps

Statistics

Views

Total Views
744
Views on SlideShare
744
Embed Views
0

Actions

Likes
0
Downloads
27
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Calabash iOS consists of two parts: a client library written in Ruby, and calabash.framework, a server framework written in Objective-C (a Clojure/JVM version of the client is coming too). To use calabash you make a special test target in XCode that links with calabash.framework. The application is 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. Here is an illustration:

Calabash for iPhone apps Calabash for iPhone apps Presentation Transcript

  • CALABASH For iPhone Apps By Chathura Palihakkara.
  • ROAD MAP • What is calabash • Main Components • Simple demo • Q&A • Getting started
  • 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
  • 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
  • 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).
  • 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.
  • 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
  • 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
  • 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
  • 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
  • REPORTS Several types of detailed calabash repots
  • DEMO
  • 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 "calabash@leapset.com" pass "chathura123" And I wait until UIActivityIndicator is gone Then I should see myAccount screen Then I see the text "calabash@leapset.com" 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
  • DIRECTORY STRUCTURE Project root Features folder Step_definition folder
  • 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
  • RESULT
  • Q&A
  • 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 https://github.com/calabash/calabash-ios
  • 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.
  • 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)
  • 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).
  • Configure iPhone App • Download the latest version of calabash-ios at https://s3.amazonaws.com/calabashapp/Calabash.zip • 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
  • Configure iPhone App You should see like this.
  • 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
  • Configure iPhone App • Find "Valid Architectures" in Build Settings and Add "i386" for the new target.
  • 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++
  • 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.
  • 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
  • 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. https://github.com/QuBiT/cucumber-netbeans-plugin/wiki/Install
  • Q&A