Using the built-in testing framework provided by Xcode, is there any way for application code to determine whether it is being run by the test runner, as opposed to running as the app?
In other words, I'm wondering whether it is possible to do something like this in the application code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
if (IsUnitTestRunning()) {
[self useDefaultSettings];
[self showDefaultViewController];
}
else {
[self restoreUserSettings];
[self restoreUserInterface];
}
// ...
}
I know I could create a new configuration that defines some precompiler macros and set the Xcode scheme to build and use that configuration when running a test, or I could set some sort of global variable in my app to YES when running a test, but I'm wondering whether there is already something built into OCUnit or Xcode to handle this.