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 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.