Hiding Test-Setup Code from Release

Since we’re embedding a data factory into our application code, we should consider the impact this could have out in the wild. NearbyMe is a simple application, and an average user wouldn’t be able to set environment variables to trigger these destructive data operations, so it doesn’t matter much in this case. But if you have sensitive setup information for automated tests in your own applications, you may not want to compile the code paths that activate it, or even compile test-code files at all.

We’re going to practice forking our code so test-specific setup code exists only in our test-specific build. We’ll start by setting up a separate target that our test scheme will use. We’ll utilize preprocessor ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.