Skip to content

Instantly share code, notes, and snippets.

@kzim44
Created July 3, 2014 00:54
Show Gist options
  • Save kzim44/7a7aac6b8a9485c3091e to your computer and use it in GitHub Desktop.
Save kzim44/7a7aac6b8a9485c3091e to your computer and use it in GitHub Desktop.
Alternate AppDelegate for XCTest
//I had a need to use a different app delegate in Convene’s XCTest suite today, so I took the time to figure out how to do it.  Quite simple really:
//Switch your main.m to:
@autoreleasepool {
BOOL runningTests = NSClassFromString(@"XCTestCase") != nil;
if (!runningTests) {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([CVNAppDelegate class]));
} else {
return UIApplicationMain(argc, argv, nil, @"CVNTestAppDelegate");
}
}
/*
Add your test app delegate to your test target looking like:
CVNTestAppDelegate.h
@interface CVNTestAppDelegate : NSObject<UIApplicationDelegate>
 
@end
CVNTestAppDelegate.m
#import "CVNTestAppDelegate.h"
@implementation CVNTestAppDelegate
 
@end
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment