The Chronicle of iPhone Automation -- From Frank to UISpec to UIAutomation to KIF
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

The Chronicle of iPhone Automation -- From Frank to UISpec to UIAutomation to KIF

on

  • 2,876 views

 

Statistics

Views

Total Views
2,876
Views on SlideShare
2,876
Embed Views
0

Actions

Likes
1
Downloads
13
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

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

The Chronicle of iPhone Automation -- From Frank to UISpec to UIAutomation to KIF Presentation Transcript

  • 1. The Chronicle of iPhone Automation
    From Frank to UISpec to UIAutomation to KIF
    HinlingYeung
    QA Automation Engineer from Trulia, Inc
  • 2. Background
    iPhone app
    iPad app
    Android app
    Mobile site
    more phone/device apps to come in a short future
    Mobile traffic keeps increasing
  • 3. To help maintain our sanity…
    Let’s automate some of our devices!
  • 4. Now let’s get back to the topic.
    After watching Pete Hodgson’s presentation about Frank, I was very hopeful about iPhone automation…
  • 5. Then I follow the online documentations…
    And successfully setup up Frank!
  • 6. However, when I actually start automating my first test case.
    I hit my first wall:
  • 7. mbp-1350:cucumber hyeung$ cucumber features/login.feature
    Feature:
    As an iOS developer
    I want to click the Log in button
    So I can see the warning message of missing email address and password
    Scenario: # features/login.feature:6
    PING FAILED!!!!
    FRANK! Given I launch the app # features/step_definitions/launch_steps.rb:1
    When I wait 30 seconds # features/step_definitions/frank_steps.rb:1
    When I touch the "No Thanks" Button # features/step_definitions/frank_steps.rb:29
    end of file reached (EOFError)
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:135:in `sysread'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:93:in `timeout'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:126:in `readline'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2020:in `read_status_line'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2009:in `read_new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:1050:in `request'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:543:in `start'
    ./features/step_definitions/frank_steps.rb:30:in `/^I touch the "([^"]*)" Button$/'
    features/login.feature:9:in `When I touch the "No Thanks" Button'
    Failing Scenarios:
    cucumber features/login.feature:6 # Scenario:
    1 scenario (1 failed)
    3 steps (1 failed, 2 passed)
    0m37.113s
  • 8. So…
    Keep on debugging the ruby scripts, Frank, and possibly UISpec
    OR
    Let’s get to the bottom: UISpec
  • 9. Then I start setting up UISpec…
    adding libraries…
    Adding dependencies…
    Adding header files…
    Adding more header files…
    Oops…linking error. Then adding .m files…
    Add some test code:
    -(void)itShouldShowErrorMessageAfterClickingLogInButton {
    [[app.find.labeltext:@"For Sale"] flash];
    [[app.find.labeltext:@"For Rent"] flash];
    [[app.find.labeltext:@"My Trulia"] flash];

    }
  • 10. Looks Really Promising…
    Let’s try “touch” it instead of just “flash” it.
    Then I hit another wall:
    “touch” results in no reaction or EXC_BAD_ACESS error
  • 11. Sigh…
  • 12. I really need something that just work!
    Then I talked to a friend of mine who works in the MobileMe automation team in Apple:
    Me: What do you use to automate your iphone app?
    Friend: Javascript
    Me: Javascript? You mean Javascript JAVASCRIPT? The one we use on the browser?
    Friend: yes. Check the apple dev center.
    Results: UIAutomation from Apple
  • 13. UIAutomation with Instruments
    http://alexvollmer.com/posts/2010/07/03/working-with-uiautomation/
    Add some accessibilityLabels
    Setup the Instruments template
    Write some Javascript
    A little counter intuitive but click “record” and it starts running.
    And it works!
  • 14.
  • 15. Let’s integrate the tests with Jenkins
    I hit another wall:
    There is no good way to kick off the tests from command line and integrate my results to Jenkins!
  • 16. Then I found KIF…
    KIF – Keep It Functional
    By Square (Eric Firestone) -- https://github.com/square/KIF
    Blog: http://corner.squareup.com/2011/07/ios-integration-testing.html
    Couple linking errors later…
  • 17. YEAH!
    It actually works from end to end with simple enough setup.
    With instructions to start the test in command line
    And quits after the test finish running.
    And output results to the console.
    Results are not in a CI-ready format but THAT’S OK IF THAT’S THE ONLY PROBLEM!
  • 18. Final Solution
    KIF
    Add accessibilityLabel to textField, Button, and View
    isAccessibilityElement = YES
    Symbiote from Frank to inspect the labels on app
    WaxSim to launch app from command line
    Modify the KIF log to output test results that can be turned into standard junit result format