Test iOS Apps with UI Automation

Book description

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.

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.

Table of contents

  1. Test iOS Apps with UI Automation
  2. For the Best Reading Experience...
  3. Table of Contents
  4. Early Praise for Test iOS Apps with UI Automation
  5. Acknowledgments
  6. Introduction
    1. What Can We Do About It?
    2. Great, So How Do We Get There?
    3. Expectations and Technical Requirements
  7. Chapter 1: UI Automation Overview
    1. Capturing Our First Script from the Simulator
    2. Finding Our Way around UI Automation
  8. Chapter 2: Testing Behavior with UI Automation
    1. Talking to the UI through JavaScript
    2. Reporting Errors
    3. Verifying that the Test Does What It Says
  9. Chapter 3: Building a Test Suite
    1. Testing with a Modal Alert View
    2. Importing Script Files at Runtime
    3. Testing Results from a Live API
    4. Grouping Test Steps and Their Output
  10. Chapter 4: Organizing Test Code
    1. Starting a JavaScript Toolbox
    2. Describing the App with Screen Objects
    3. Reusing a Generic Screen Prototype
    4. Converting Our Test Suite to Screen Objects
  11. Chapter 5: Maps, Gestures, and Alerts
    1. Exploring the Map
    2. Identifying Elements with Accessibility APIs
    3. Testing with Gestures
    4. Advanced Alert-Handling
  12. Chapter 6: Strategies for Testing Universal Apps
    1. Universalizing an Application
    2. Finding Elements in the New Idiom
    3. Building an iPad Test Suite with Reusable Pieces
    4. Searching the Element Tree with Predicates
    5. Advanced Predicate Usage and Beyond
  13. Chapter 7: Automating Performance Tests
    1. Setting Up Custom Instruments Templates
    2. Capturing Steps to Reproduce a Memory Leak
    3. Triggering Simulator Memory Warnings with AppleScript
    4. Stress Testing
  14. Chapter 8: Setting Up Application Data
    1. Seeding Data in Xcode with Application Data Packages
    2. Seeding Data Dynamically with a Factory
    3. Choose Your Own Adventure with Environment Variables
    4. Hiding Test-Setup Code from Release
  15. Chapter 9: Stubbing External Services
    1. Choosing a Geographical Location
    2. Faking a Network-Service API
    3. Wrapping Service APIs in a Facade
    4. Stubbing a Facade with Data in the App Bundle
  16. Chapter 10: Command-Line Workflow
    1. Practicing with the Raw Commands
    2. Automating the Build-and-Run Process with Rake
    3. Reading Environment Variables from Script Files
    4. Resetting the Simulator to Test Permissions
    5. Running Tests on an Attached Device
  17. Chapter 11: Third-Party Tools and Beyond
    1. Enhancing UI Automation
    2. Testing outside the Box
  18. Appendix 1: Bibliography
    1. You May Be Interested In…

Product information

  • Title: Test iOS Apps with UI Automation
  • Author(s): Jonathan Penn
  • Release date: August 2013
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781937785529