19
The Chronicle of iPhone Automation From Frank to UISpec to UIAutomation to KIF Hinling Yeung QA Automation Engineer from Trulia, Inc

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

  • View
    2.825

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

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

The Chronicle of iPhone Automation

From Frank to UISpec to UIAutomation to KIF

Hinling YeungQA Automation Engineer from Trulia, Inc

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

Background

• iPhone app• iPad app• Android app• Mobile site• more phone/device apps to come in a short

future• Mobile traffic keeps increasing

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

To help maintain our sanity…

Let’s automate some of our devices!

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

Now let’s get back to the topic.

• After watching Pete Hodgson’s presentation about Frank, I was very hopeful about iPhone automation…

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

Then I follow the online documentations…

• And successfully setup up Frank!

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

However, when I actually start automating my first test case.

I hit my first wall:

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

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

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

So…

• Keep on debugging the ruby scripts, Frank, and possibly UISpec

• OR

• Let’s get to the bottom: UISpec

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

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.label text:@"For Sale"] flash]; [[app.find.label text:@"For Rent"] flash]; [[app.find.label text:@"My Trulia"] flash]; …}

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

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

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

Sigh…

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

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: JavascriptMe: Javascript? You mean Javascript JAVASCRIPT? The one we use on the

browser?Friend: yes. Check the apple dev center.

• Results: UIAutomation from Apple

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

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!

Page 14: The Chronicle of iPhone Automation -- From Frank to UISpec to UIAutomation to KIF
Page 15: The Chronicle of iPhone Automation -- From Frank to UISpec to UIAutomation to KIF

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!

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

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…

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

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!

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

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

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