From 9f34bd888691f72b512effab43b3c55f51e7ba92 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Humpert Date: Fri, 22 Jul 2011 11:17:48 +0200 Subject: [PATCH] Statische Erfassung von Examples und Failures --- src/TTestCase.m | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/TTestCase.m b/src/TTestCase.m index 599d9a8..8cdb3b3 100644 --- a/src/TTestCase.m +++ b/src/TTestCase.m @@ -439,6 +439,7 @@ - (int)run: (NSString *)methodFilter if (([method hasPrefix: @"test"] || [method hasPrefix: @"itShould"]) && (nil == methodFilter || [method matches: methodFilter]) && ![method matches: @"Broken$"]) { + [TTestCaseStatistics countExample]; TStack *exceptions = [TStack stack]; @try { [self clearHint]; @@ -466,6 +467,7 @@ - (int)run: (NSString *)methodFilter } if ([exceptions containsData]) { ++failures; + [TTestCaseStatistics countFailure]; [TUserIO eprintln: @"ERROR: Test %@:%@ failed - %@", [self className], method, [exceptions pop]]; while ([exceptions containsData]) { @@ -516,6 +518,38 @@ - (TString *)testBaseDir @end +@implementation TTestCaseStatistics:NSObject + + +static unsigned int __examples = 0; ++ (void)countExample +{ + __examples++; +} + + ++ (unsigned int)exampleCount +{ + return __examples; +} + + +static unsigned int __failures = 0; ++ (void)countFailure +{ + __failures++; +} + + ++ (unsigned int)failureCount +{ + return __failures; +} + + +@end + + int objcmain(int argc, char *argv[]) { int result = 0; @@ -552,5 +586,14 @@ int objcmain(int argc, char *argv[]) [test release]; } } + [TUserIO eprintln: @"%u examples, %u failures", + [TTestCaseStatistics exampleCount], + [TTestCaseStatistics failureCount]]; + + if (result > 0) { + [TUserIO println: @"*** RED BAR ***"]; + } else { + [TUserIO println: @"*** GREEN BAR ***"]; + } return result; }