From 90eba8f973c0b77f36dc7084163ff0d43675a1a8 Mon Sep 17 00:00:00 2001 From: "thomasvl@gmail.com" Date: Thu, 25 Sep 2008 20:46:41 +0000 Subject: fix double printing of failures on the iphone unittests --- UnitTesting/GTMSenTestCase.h | 5 +---- UnitTesting/GTMSenTestCase.m | 21 +++++++++------------ 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)]; -- cgit v1.2.3