Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AppDelegate.m
- @implementation AppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- if (isRunningTests()) return YES;
- // ...
- return YES;
- }
- BOOL isRunningTests(void)
- {
- NSDictionary* environment = [[NSProcessInfo processInfo] environment];
- NSString* injectBundle = environment[@"XCInjectBundle"];
- return [[injectBundle pathExtension] isEqualToString:@"xctest"];
- }
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- if (isRunningTests()){
- // This bundle has unit tests injected. Let's not really start the app to avoid interfering with the tests.
- id infoDictionary = [[NSBundle mainBundle] infoDictionary];
- [infoDictionary setValue:@"UnitTest" forKey:@"UIMainStoryboardFile"];
- }
- }
- return self;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement