Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/TTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}