Watch_me

If you’re an iOS developer or QA professional tapping through an app to reproduce bugs or performance issues you thought were solved two releases ago, then this is your book. Learn how to script the user interface, assert correct behavior, stub external dependencies, reproduce performance problems, organize test code for the long haul, and automate the whole process so the machine does the work. You’ll walk through a comprehensive strategy with techniques using Apple’s tools that you can apply to your own apps.

Buy Now

Select a DRM-free Format:

In Stock
In Stock
In Stock
Buy the eBook and get these DRM-free formats delivered immediately:
  • epub (for iPhone/iPad, Android, eReaders)
  • mobi (for Kindle)
  • PDF
We can automatically send them to your Kindle or Dropbox, and for a social reading experience we can link the book to your Readmill account. (You'll need to log in to enable these options.)
 

About this Book

  • 226 pages
  • Published:
  • Release: P1.0 (2013-08-14)
  • ISBN: 978-1-93778-552-9

Automated user interface testing is an important part of a comprehensive testing strategy for iOS applications. By scrutinizing your app through the eyes and actions of the user, you raise confidence that features are wired up right and behave as you expect.

Through this book you’ll learn how to do full-stack testing of your iOS apps in both the simulator and on the device with Apple’s built-in tools. You’ll write behavioral tests in UI Automation that help protect against regressions. You’ll write scripts to repeat steps in Instruments to reproduce performance bugs. With a little ingenuity, you’ll build a workflow that gives the feedback you need.

Grow a test suite by working with a real application that uses Core Data and network requests. Learn how to describe expected behavior in test scripts, launch the app in a specific state, and stub external dependencies for completely isolated and repeatable tests. Along the way, you’ll practice how to organize your test code and run it hands-free from the command line. By the end, you’ll have the tools and habits you need to tackle the unique testing problems you’ll face while building best-of-breed native iOS apps for your users.

What You Need

You’ll need a Mac running at least Mac OS X Lion (10.7) and Xcode 4.6.

Contents and Extracts

  • Introduction
    • What Can We Do About It?
    • The Road Ahead
    • Expectations and Technical Requirements
    • Online Resources
  • UI Automation Overview
  • Testing Behavior With UI Automation
    • Talking The UI Through JavaScript
    • Reporting Errors
    • Verifying The Test Does What It Says
  • Building Up A Test Suite
    • Testing With A Modal Alert View
    • Importing Script Files At Runtime
    • Testing Results From A Live API
    • Grouping Test Steps And Their Output
  • Organizing Test Code
    • Starting A JavaScript Toolbox
    • Describing The App With Screen Objects
    • Reusing A Generic Screen Prototype
    • Converting Our Test Suite To Screen Objects
  • Maps, Gestures, and Alerts
  • Strategies For Testing Universal Apps
  • Automating Performance Tests
    • Setting Up Custom Instruments Templates
    • Capturing Steps To Reproduce A Memory Leak
    • Triggering Simulator Memory Warnings With AppleScript
    • Stress Testing
  • Setting Up Application Data
    • Seeding Data in Xcode With Application Data Packages
    • Seeding Data Dynamically With A Factory
    • Choose Your Own Adventure With Environment Variables
    • Hiding Test Setup Code From Release
  • Stubbing External Services
    • Choosing A Geographical Location
    • Faking A Network Service API
    • Wrapping Service APIs In A Facade
    • Stubbing A Facade With Data In The App Bundle
  • Command Line Workflow
    • Practicing With The Raw Commands
    • Automating The Build and Run Process With Rake
    • Reading Environment Variables From Script Files
    • Resetting The Simulator To Test Permissions
    • Running Tests On a Connected Device
  • Third Party Tools And Beyond
    • Enhancing UI Automation
    • Testing Outside The Box

About the Author

Jonathan Penn is a software developer with a long history of quality work sprinkled with mischief. When not consulting with clients, he speaks at conferences, is the mad scientist behind the featured apps at navel-labs.com, and is scribbler-in-chief at cocoamanifest.net, a technical blog for exceptional iOS resources and commentary.

Upcoming Author Events

  • 2012-11-30: Jonathan Penn
    RubyMotion - Ruby and Cocoa Touch Sitting In A Tree… (CocoaConf Raleigh)
  • 2012-12-01: Jonathan Penn
    UI Automation for iOS Applications: Automation ALL THE THINGS! (CocoaConf Raleigh)
  • 2013-01-10: Jonathan Penn
    RubyMotion - Ruby and Cocoa Touch Sitting In A Tree… (CodeMash 2013)
  • 2013-03-07: Jonathan Penn
    Game Dev Workshop (CocoaConf Chicago)
  • 2013-03-08: Jonathan Penn
    Zen and the Art of iOS Gesture Recognizers (CocoaConf Chicago)
  • 2013-03-09: Jonathan Penn
    UI Automation - Automate ALL THE THINGS! (CocoaConf Chicago)
  • 2013-03-25: Jonathan Penn
    CoreData In Motion - An overview of how CoreData works, when to use it, and how to use it in RubyMotion (#inspect 2013 - Brussels, Belgium)
  • 2013-04-05: Jonathan Penn
    Zen and the Art of iOS Gesture Recognizers (CocoaConf Dallas)
  • 2013-04-06: Jonathan Penn
    Advanced UI Automation Techniques (CocoaConf Dallas)
  • 2013-04-19: Jonathan Penn
    Advanced UI Automation Techniques (CocoaConf San Jose)
  • 2013-04-19: Jonathan Penn
    Zen and the Art of iOS Gesture Recognizers (CocoaConf San Jose)
  • 2013-04-27: Brian P. Hogan
    JRuby - Imagine mixing the easy syntax, powerful language features, and rapid development of Ruby with the speed, power, and flexibility of the Java Virtual Machine? Ruby and the JVM go together like chocolate and peanut butter, and you'll see some examp (Twin Cities Code Camp, Minneapolis, MN)
  • 2013-05-03: Jonathan Penn
    HTTP: Get to Know the Foundations of Your Career (Rustbelt Refresh)
  • 2013-05-23: Jonathan Penn
    UI Automation for Great Awesome (Cincinnati CocoaHeads (Cincinnati, OH))
  • 2013-07-01: Jonathan Penn
    iOS Gesture Recognizers (Indianapolis CocoaHeads)
  • 2013-08-12: Jonathan Penn
    Building Native iOS Apps With RubyMotion (That Conference (Wisconsin Dells))
  • 2013-08-13: Brian P. Hogan
    Testing Client Side Code with Jasmine and CoffeeScript With more logic moving from the client-side to the server-side, we've got to get better at testing code. In this talk you'll learn about writing tests for client-side code that help drive the d (ThatConference, Wisconsin Dells, Wisconsin)
  • 2013-08-14: Jonathan Penn
    iOS 2D Game Development Workshop (CocoaConf Portland)
  • 2013-08-15: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf Portland)
  • 2013-08-16: Jonathan Penn
    Testing iOS Apps With UI Automation (CocoaConf Portland)
  • 2013-09-27: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf Columbus)
  • 2013-09-27: Jonathan Penn
    Intro to iOS Gesture Recognizers (CocoaConf Columbus)
  • 2013-10-12: Jonathan Penn
    Testing on iOS With New Hotness (CocoaSlopes (Ogden, Utah))
  • 2013-10-24: Jonathan Penn
    iOS 2D Game Development Workshop (CocoaConf Boston)
  • 2013-10-25: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf Boston)
  • 2013-10-26: Jonathan Penn
    Zen And The Intro To iOS Gesture Recognizers (CocoaConf Boston)
  • 2013-11-14: Jonathan Penn
    iOS 2D Game Development Workshop (CocoaConf Atlanta)
  • 2013-11-15: Jonathan Penn
    Testing in Xcode 5 (CocoaConf Atlanta)
  • 2013-11-16: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf Atlanta)
  • 2014-01-09: Jonathan Penn
    Physics and the User Interface on iOS (CodeMash - Sandusky, OH)
  • 2014-01-10: Jonathan Penn
    Zen and an Intro to iOS Gesture Recognizers (CodeMash - Sandusky, OH)
  • 2014-02-06: Jonathan Penn
    Physics And The User Interface for iOS (CocoaHeads Toledo, OH)
  • 2014-02-18: Jonathan Penn
    RubyMotion Q&A From A Long Time iOS Dev (RubyMotion Chicago Meetup)
  • 2014-03-06: Jonathan Penn
    Sprite Kit Game Development Workshop (CocoaConf Chicago)
  • 2014-03-07: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf Chicago)
  • 2014-03-08: Jonathan Penn
    Testing in Xcode 5 (CocoaConf Chicago)
  • 2014-03-27: Jonathan Penn
    Sprite Kit Game Development Workshop (CocoaConf DC)
  • 2014-03-28: Jonathan Penn
    Testing in Xcode 5 (CocoaConf DC)
  • 2014-03-28: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf DC)
  • 2014-04-04: Jonathan Penn
    Sure, UIKit Dynamics... But Is It A Good Idea? (CocoaConf Austin 2014)
  • 2014-04-05: Brian P. Hogan
    Automate with Grunt (Twin Cities Code Camp, Minneapolis, MN)
  • 2014-04-25: Jonathan Penn
    NSIncrementalStore - Bet you didn't think Core Data could do *that*! (CocoaConf San Jose 2014)

Comments and Reviews

  • Jonathan Penn is the perfect person to teach you how to test your iOS apps with UI Automation. He is passionate about testing and has a lot of experience both in iOS development and in the JavaScript required to make your tests sing. This book is filled with techniques you’ll use immediately to make your iOS apps more robust.

    —Daniel Steinberg, Dim Sum Thinking
  • Automated testing is essential to delivering quality software. In this book Jonathan lays out the details of how to use the UI Automation tools to build a test suite that will keep your app in tip-top shape.

    —Bill Dudney
  • Automated testing is a technique that every developer can benefit from. It’s a dry topic, but Jonathan is able to bring clarity, comedy, and context to a very useful though poorly documented tool.

    —Josh Smith
  • Web-to-mobile converts often find it challenging to bring their automated-testing habits with them, due in part to the fact that touch gestures and native UI widgets are much harder to expose to automated testing than HTTP requests and HTML output. Apple’s UI Automation is a big step in the right direction in this regard, but it takes the guidance of a pioneer like Jonathan Penn to assemble a full repertoire of developer tools to extend the reach of Apple’s tools and achieve a high level of code confidence.

    —Chris Adamson
  • My iOS development knowledge has been raised a notch by reading this book. It’s great that I could take my existing JavaScript skills and learn how to apply them to the field of iOS testing. I’ll definitely be using these techniques on the next app I build!

    —Stephen Orr, Lead Developer, Made Media
  • Being a big advocate of automated acceptance testing myself, in the past few years UI Automation has become my weapon of choice for iOS applications. Jonathan Penn is an absolute authority on the topic and his work has made my life easier too many times to count. Now whenever people ask for advice on the topic, I can just point them to this book, and it will answer all their questions and then some.

    —Alexander Repty
  • Jonathan’s book is the best I’ve read about building great automated tests for your iOS applications. The book has clear and comprehensive examples that help you understand how to write great tests for your own projects. Not only does he show you how to write solid tests; he shares best practices and techniques to maintain a test suite as it grows. If you want to go beyond unit tests and automate your app end-to-end, this book will get you started.

    —Shiney Rossi, Senior Mobile Engineer, Nest Labs
  • Jonathan Penn succeeds at opening up the world of UI Automation testing to everyone with his new book, Test iOS Apps with UI Automation. From acceptance testing to performance testing, Test iOS Apps covers all the steps to go from zero to a full suite of automated tests that will help make your apps better. Sit down and enjoy this engaging book to learn how to automate everything!

    —Conrad Stoll, Software Engineer, Mutual Mobile