O'Reilly logo

Test iOS Apps with UI Automation by Jonathan Penn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stubbing a Facade with Data in the App Bundle

Now that we’ve seen a service-facade architecture at work in the application, controlling it in our test environment is quite straightforward. We’ll override the findByText:within: method in a subclass NBMPointsOfInterestService and have it return whatever data we want. We need to figure out how to use this special subclass instead of the normal one when running in the test environment.

Using a Subclass Instead of a Superclass

There are a lot of ways to substitute one class for another on the fly. We could conjure elaborate Objective-C runtime magic by changing pointers or swizzling, but we don’t have to get that fancy here. We have full control over these classes, and all we have to do is follow ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required