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 "([^quot;]*)" 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
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