aboutsummaryrefslogtreecommitdiff
path: root/UnitTesting
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-08-10 19:30:20 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-08-10 19:30:20 +0000
commit24b6e2d377ad55e269297977ade4bfd98df7fc5a (patch)
treebfa3229d9bd73ae6f126bd96c2a6d37781cdb036 /UnitTesting
parent89ad9ae8def4ada78f4affe1cbf9e0d8a734ac79 (diff)
[Author: honza]
Running iOS unit tests outside of applicationDidFinishLaunching: R=dmaclach,thomasvl APPROVED=dmaclach DELTA=12 (12 added, 0 deleted, 0 changed)
Diffstat (limited to 'UnitTesting')
-rw-r--r--UnitTesting/GTMIPhoneUnitTestDelegate.m12
1 files changed, 12 insertions, 0 deletions
diff --git a/UnitTesting/GTMIPhoneUnitTestDelegate.m b/UnitTesting/GTMIPhoneUnitTestDelegate.m
index 6d56602..aecd448 100644
--- a/UnitTesting/GTMIPhoneUnitTestDelegate.m
+++ b/UnitTesting/GTMIPhoneUnitTestDelegate.m
@@ -46,6 +46,9 @@
// We also check to make sure we aren't called twice with the
// applicationDidFinishLaunchingCalled flag.
@property (readwrite, retain, nonatomic) GTMIPhoneUnitTestDelegate *retainer;
+
+- (void)runTestsAndExit:(UIApplication *)application;
+
@end
@implementation GTMIPhoneUnitTestDelegate
@@ -80,6 +83,15 @@
name:UIApplicationDidFinishLaunchingNotification
object:[UIApplication sharedApplication]];
+ // To permit UI-based tests, run the tests and exit app in a delayed selector
+ // call. This ensures tests are run outside of applicationDidFinishLaunching:.
+ [self performSelector:@selector(runTestsAndExit:)
+ withObject:application
+ afterDelay:0];
+}
+
+// Run through all tests and then exit application if required.
+- (void)runTestsAndExit:(UIApplication *)application {
[self runTests];
if (!getenv("GTM_DISABLE_TERMINATION")) {