Chapter 4Organizing Test Code

One of the greatest challenges we face in automated UI testing is the brittle coupling between our test code and the app’s interface. For example, if we have to move a button out of one superview and into another, or if the name of the button changes, then our tests will break. If we have to push that button in ten separate test scenarios, then we have ten places to update. This is what we mean when we say brittle; changes in the UI cause catastrophic changes in our tests. We can’t always avoid writing brittle tests, but we can take steps to minimize the damage.

Another challenge is the line noise from the verbose scripting interface of UI Automation. Walking down the element tree to interact with the UI takes ...

Get Test iOS Apps with UI Automation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.