Commits

Jens Alfke committed 2eda339

RunTestCases now logs the names of all failed tests at the end, so you don't have to scroll back up looking for them.

  • Participants
  • Parent commits c4aeedf

Comments (0)

Files changed (1)

 
 struct TestCaseLink *gAllTestCases;
 static int sPassed, sFailed;
+static NSMutableArray* sFailedTestNames;
 static int sCurTestCaseExceptions;
 
 
     Log(@"XXX FAILED test case -- backtrace:\n%@\n\n", x.my_callStack);
 }
 
+static void RecordFailedTest( struct TestCaseLink *test ) {
+    if (!sFailedTestNames)
+        sFailedTestNames = [[NSMutableArray alloc] init];
+    [sFailedTestNames addObject: [NSString stringWithUTF8String: test->name]];
+}
+
 static BOOL RunTestCase( struct TestCaseLink *test )
 {
     BOOL oldLogging = EnableLog(YES);
                 Log(@"XXX FAILED test case '%s' due to %i exception(s) already reported above",
                     test->name,sCurTestCaseExceptions);
                 sFailed++;
+                RecordFailedTest(test);
             }
         }@catch( NSException *x ) {
             if( [x.name isEqualToString: @"TestCaseSkipped"] )
                 Log(@"XXX FAILED test case '%s' due to:\nException: %@\n%@\n\n", 
                       test->name,x,x.my_callStack);
                 sFailed++;
+                RecordFailedTest(test);
             }
         }@finally{
             [pool drain];
 void RunTestCases( int argc, const char **argv )
 {
     sPassed = sFailed = 0;
+    sFailedTestNames = nil;
     BOOL stopAfterTests = NO;
     for( int i=1; i<argc; i++ ) {
         const char *arg = argv[i];
         }
     }
     if( sPassed>0 || sFailed>0 || stopAfterTests ) {
+        NSAutoreleasePool *pool = [NSAutoreleasePool new];
         if( sFailed==0 )
             AlwaysLog(@"√√√√√√ ALL %i TESTS PASSED √√√√√√", sPassed);
         else {
-            Warn(@"****** %i TESTS FAILED, %i PASSED ******", sFailed,sPassed);
+            Warn(@"****** %i of %i TESTS FAILED: %@ ******", 
+                 sFailed, sPassed+sFailed,
+                 [sFailedTestNames componentsJoinedByString: @", "]);
             exit(1);
         }
         if( stopAfterTests ) {
             Log(@"Stopping after tests ('Test_Only' arg detected)");
             exit(0);
         }
+        [pool drain];
     }
+    [sFailedTestNames release];
+    sFailedTestNames = nil;
 }