This talk begins with a survey of the landscape of iPhone UI testing. We’ll discuss the work done by Dr. Nic Williams in unit-testing Objective-C code with RSpec, and by Matt Gallagher in spidering the iPhone UI with an XPath test script.
That will be a natural jumping-off point to explain why a full-fledged “GUI driver” for iPhone apps has been long in coming. We’ll look at different ways to prod at application code, and discuss the tradeoffs. Finally, I’ll introduce a simple library of Ruby glue code to connect Cucumber test scripts to the iPhone. The technique will be very basic, but just powerful enough to test a simple iPhone app.
Ian Dees saw his first Timex Sinclair 1000 over 20 years ago, and was instantly hooked. Since then, he’s debugged embedded assembly code using an oscilloscope, written desktop apps in C++, and joyfully employed scripting languages to make testing less painful. Ian currently writes GUI code for handheld instruments as a Software Engineer at Tektronix.
Ian is the author of the book Scripted GUI Testing With Ruby.
Add a comment (requires login)
For information on exhibition and sponsorship opportunities at the conference, contact Sharon Cordesse at scordesse@oreilly.com
Download the OSCON Sponsor/Exhibitor Prospectus
Download the Media & Promotional Partner Brochure (PDF) for information on trade opportunities with O'Reilly conferences or contact mediapartners@ oreilly.com
For media-related inquiries, contact Maureen Jennings at maureen@oreilly.com
To stay abreast of conference news and to receive email notification when registration opens, please sign up for the OSCON newsletter (login required)
View a complete list of OSCON contacts
Comments
Questions and answers from the audience on the day of the talk:
Q : Is it possible to grab live camera data from an automated script?
A : Probably not with this technique. It is possible, however, to feed canned image data into your app’s test hooks as if it had come from the camera. The idea is a bit like the “faking the time” discussion starting on slide 45.
Q : What’s the applicability of this approach to testing games?
A : Not much, alas; the code here is heavily UIKit-centric. A simple word puzzle app might be UIKit-based. But for heavily graphical games, you’re more likely to benefit from something like Google’s technique of capturing screen images (link: http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting#UI_and_State_Testing) and comparing them against a reference.
Q : How do you protect the tests against changes in the GUI, like a button moving?
A : For small changes like buttons moving, use the “tag” property of UIView to identify your interface elements, rather than tapping on specific screen coordinates. For more disruptive changes like using a completely different set of controls, wrap your app’s GUI in an ad-hoc API, and have your tests script say things like “delete the blog post” instead of “click the Delete link.”
Q : Can you use Ruby to test the individual classes of an iPhone app (in addition to testing the whole GUI)?
A : Yes; see Dr. Nic’s Unit Testing iPhone apps with Ruby (link: http://drnicwilliams.com/2008/07/04/unit-testing-iphone-apps-with-ruby-rbiphonetest) article.