aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-09-25 20:46:41 +0000
committerGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-09-25 20:46:41 +0000
commit90eba8f973c0b77f36dc7084163ff0d43675a1a8 (patch)
tree4903eceacf4b141eea70cc28f3f86d0d42ec917c
parent511053a03ce1f92a21ce9c9ba58fea3507624502 (diff)
fix double printing of failures on the iphone unittests
-rw-r--r--UnitTesting/GTMSenTestCase.h5
-rw-r--r--UnitTesting/GTMSenTestCase.m21
2 files changed, 10 insertions, 16 deletions
diff --git a/UnitTesting/GTMSenTestCase.h b/UnitTesting/GTMSenTestCase.h
index 67f7dad..4a2bc9f 100644
--- a/UnitTesting/GTMSenTestCase.h
+++ b/UnitTesting/GTMSenTestCase.h
@@ -979,10 +979,6 @@ do { \
// SENTE_END
-@interface NSObject (GTMSenTestAdditions)
-- (void)failWithException:(NSException*)exception;
-@end
-
@interface SenTestCase : NSObject {
SEL currentSelector_;
}
@@ -991,6 +987,7 @@ do { \
- (void)invokeTest;
- (void)tearDown;
- (void)performTest:(SEL)sel;
+- (void)failWithException:(NSException*)exception;
@end
CF_EXPORT NSString * const SenTestFailureException;
diff --git a/UnitTesting/GTMSenTestCase.m b/UnitTesting/GTMSenTestCase.m
index f8d7ff3..856516c 100644
--- a/UnitTesting/GTMSenTestCase.m
+++ b/UnitTesting/GTMSenTestCase.m
@@ -109,13 +109,6 @@
@end
-@implementation NSObject (GTMSenTestAdditions)
-- (void)failWithException:(NSException*)exception {
- [exception raise];
-}
-
-@end
-
NSString *STComposeString(NSString *formatString, ...) {
NSString *reason = @"";
if (formatString) {
@@ -135,6 +128,10 @@ NSString * const SenTestFailureException = @"SenTestFailureException";
@end
@implementation SenTestCase
+- (void)failWithException:(NSException*)exception {
+ [exception raise];
+}
+
- (void)setUp {
}
@@ -164,23 +161,23 @@ NSString * const SenTestFailureException = @"SenTestFailureException";
// have an STMacro in their dealloc which may get called
// when the pool is cleaned up
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ // We don't log exceptions here, instead we let the person that called
+ // this log the exception. This ensures they are only logged once but the
+ // outer layers get the exceptions to report counts, etc.
@try {
[self setUp];
@try {
[self performSelector:currentSelector_];
} @catch (NSException *exception) {
e = [exception retain];
- [self printError:[exception reason]];
}
[self tearDown];
} @catch (NSException *exception) {
e = [exception retain];
- [self printError:[exception reason]];
}
[pool release];
} @catch (NSException *exception) {
e = [exception retain];
- [self printError:[exception reason]];
}
if (e) {
[e autorelease];
@@ -192,10 +189,10 @@ NSString * const SenTestFailureException = @"SenTestFailureException";
}
@end
-#endif
+#endif // GTM_IPHONE_SDK
@implementation GTMTestCase : SenTestCase
-- (void) invokeTest {
+- (void)invokeTest {
Class devLogClass = NSClassFromString(@"GTMUnitTestDevLog");
if (devLogClass) {
[devLogClass performSelector:@selector(enableTracking)];