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

Faking a Network-Service API

As it is right now, our app derives its usefulness from OpenStreetMap, a relatively simple black box. We hand it a rectangle of geographical coordinates and a search string, and it returns a JSON array of dictionaries that we parse. There’s neither authentication nor any other hoops to jump through to get the information. That makes this an ideal candidate to practice building a fake service.

We’re going to build a simple web server to return consistent JSON results given a box around a geographical point. We can make the data whatever we want, and it will never change unless we change it. We’ll then learn how to point the app at our fake server when running in the test environment. Our tests will no longer depend ...

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