Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Run tests, even on CLI, inside UIApplicationMain, so instantiating vi…
Browse files Browse the repository at this point in the history
…ews in tests doesn't cause a crash
  • Loading branch information
Pretz committed Jul 1, 2011
1 parent 8cdb468 commit 9e304c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Classes-IPhone/GHUnitIPhoneAppDelegate.m
Expand Up @@ -33,6 +33,15 @@
@implementation GHUnitIPhoneAppDelegate

- (void)applicationDidFinishLaunching:(UIApplication *)application {
if (getenv("GHUNIT_CLI")) {
int exitStatus = [GHTestRunner run];
if ([application respondsToSelector:@selector(_terminateWithStatus:)]) {
[application performSelector:@selector(_terminateWithStatus:)
withObject:(id)exitStatus];
} else {
exit(exitStatus);
}
}
GHUnitIPhoneViewController *viewController = [[GHUnitIPhoneViewController alloc] init];
[viewController loadDefaults];
navigationController_ = [[UINavigationController alloc] initWithRootViewController:viewController];
Expand Down
10 changes: 2 additions & 8 deletions Project-IPhone/GHUnitIOSTestMain.m
Expand Up @@ -69,14 +69,8 @@ int main(int argc, char *argv[]) {
// Register any special test case classes
//[[GHTesting sharedInstance] registerClassName:@"GHSpecialTestCase"];

int retVal = 0;
// If GHUNIT_CLI is set we are using the command line interface and run the tests
// Otherwise load the GUI app
if (getenv("GHUNIT_CLI")) {
retVal = [GHTestRunner run];
} else {
retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIPhoneAppDelegate");
}
int retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIPhoneAppDelegate");

[pool release];
return retVal;
}

0 comments on commit 9e304c7

Please sign in to comment.