aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2013-05-13 20:00:22 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2013-05-13 20:00:22 +0000
commit99e55aa47943ab0f18767fb906c96870c983715d (patch)
tree666eff317c58f533f37b280be1ecdac619948bfd
parent53247eb0a1bbead66603837c3c71ec38e1244a62 (diff)
Added -[gtm_runUpToNSeconds:context:] to GTMFoundationUnitTestingUtilities.
Many people were using -[gtm_runUpToSixtySecondsWithContext:] which was fine until you started to see multiple failures in a single build and it could take a long time for a test pass to complete. 60 seconds is often much longer than necessary to know that a failure condition has occurred. DELTA=15 (15 added, 0 deleted, 0 changed)
-rw-r--r--UnitTesting/GTMFoundationUnitTestingUtilities.h9
-rw-r--r--UnitTesting/GTMFoundationUnitTestingUtilities.m6
2 files changed, 15 insertions, 0 deletions
diff --git a/UnitTesting/GTMFoundationUnitTestingUtilities.h b/UnitTesting/GTMFoundationUnitTestingUtilities.h
index cd37bc6..0dc8227 100644
--- a/UnitTesting/GTMFoundationUnitTestingUtilities.h
+++ b/UnitTesting/GTMFoundationUnitTestingUtilities.h
@@ -92,7 +92,16 @@
context:(id<GTMUnitTestingRunLoopContext>)context;
// Calls -gtm_runUntilDate:mode:context: with mode set to NSDefaultRunLoopMode,
+// and the timeout date set to |seconds| seconds.
+- (BOOL)gtm_runUpToNSeconds:(NSTimeInterval)seconds
+ context:(id<GTMUnitTestingRunLoopContext>)context;
+
+// Calls -gtm_runUntilDate:mode:context: with mode set to NSDefaultRunLoopMode,
// and the timeout date set to 60 seconds.
+// This is a good time to use for AppleEvent calls (which default to 60 seconds)
+// but may be a bit long for standard unit tests, and could cause a long unit
+// testing run if you have multiple failures.
+// Calling -[gtm_runUpToNSeconds:context:] is preferred.
- (BOOL)gtm_runUpToSixtySecondsWithContext:(id<GTMUnitTestingRunLoopContext>)context;
@end
diff --git a/UnitTesting/GTMFoundationUnitTestingUtilities.m b/UnitTesting/GTMFoundationUnitTestingUtilities.m
index 034c3c0..3241f81 100644
--- a/UnitTesting/GTMFoundationUnitTestingUtilities.m
+++ b/UnitTesting/GTMFoundationUnitTestingUtilities.m
@@ -81,6 +81,12 @@
@implementation NSRunLoop (GTMUnitTestingAdditions)
+- (BOOL)gtm_runUpToNSeconds:(NSTimeInterval)seconds
+ context:(id<GTMUnitTestingRunLoopContext>)context {
+ return [self gtm_runUntilDate:[NSDate dateWithTimeIntervalSinceNow:seconds]
+ context:context];
+}
+
- (BOOL)gtm_runUpToSixtySecondsWithContext:(id<GTMUnitTestingRunLoopContext>)context {
return [self gtm_runUntilDate:[NSDate dateWithTimeIntervalSinceNow:60]
context:context];