OLD | NEW |
(Empty) | |
| 1 #import "AllTests.h" |
| 2 |
| 3 #import "CDPathUnitTest.h" |
| 4 #import "CDTypeLexerUnitTest.h" |
| 5 #import "CDTypeParserUnitTest.h" |
| 6 #import "CDTypeFormatterUnitTest.h" |
| 7 #import "CDStructHandlingUnitTest.h" |
| 8 |
| 9 @interface NSObject (SenTestRuntimeUtilities) |
| 10 |
| 11 - (NSArray *) senAllSubclasses; |
| 12 - (NSArray *) senInstanceInvocations; |
| 13 - (NSArray *) senAllInstanceInvocations; |
| 14 |
| 15 @end |
| 16 |
| 17 |
| 18 @implementation AllTests |
| 19 |
| 20 // This is here to help me understand what the original method does. Formatting
/naming is key to understanding. |
| 21 + (void)_foo_updateCache; |
| 22 { |
| 23 NSEnumerator *testCaseEnumerator; |
| 24 id testCaseClass = nil; |
| 25 |
| 26 testCaseEnumerator = [[SenTestCase senAllSubclasses] objectEnumerator]; |
| 27 testCaseClass = [testCaseEnumerator nextObject]; |
| 28 while (testCaseClass != nil) { |
| 29 NSString *path; |
| 30 SenTestSuite *suite; |
| 31 |
| 32 NSLog(@"%s, testCaseClass: %@[%@]", _cmd, testCaseClass, NSStringFromCla
ss(testCaseClass)); |
| 33 NSLog(@"%s, self: %p, testCaseClass: %p", _cmd, self, testCaseClass); |
| 34 if (testCaseClass != self) { |
| 35 NSLog(@"default test suite: %@", [testCaseClass defaultTestSuite]); |
| 36 } |
| 37 #if 0 |
| 38 path = [[testCase bundle] bundlePath]; |
| 39 suite = [suiteForBundleCache objectForKey:path]; |
| 40 |
| 41 if (suite == nil) { |
| 42 suite = [self emptyTestSuiteNamedFromPath:path]; |
| 43 [suiteForBundleCache setObject:suite forKey:path]; |
| 44 } |
| 45 |
| 46 [suite addTest:[testCase defaultTestSuite]]; |
| 47 #endif |
| 48 testCaseClass = [testCaseEnumerator nextObject]; |
| 49 } |
| 50 } |
| 51 |
| 52 |
| 53 |
| 54 + (id)defaultTestSuite; |
| 55 { |
| 56 SenTestSuite *allTests, *orderedTests, *unorderedTests; |
| 57 NSMutableArray *order; |
| 58 unsigned int count, index; |
| 59 |
| 60 order = [NSMutableArray array]; |
| 61 [order addObject:[CDPathUnitTest class]]; |
| 62 [order addObject:[CDTypeLexerUnitTest class]]; |
| 63 [order addObject:[CDTypeParserUnitTest class]]; |
| 64 //[order addObject:[CDTypeFormatterUnitTest class]]; |
| 65 [order addObject:[CDStructHandlingUnitTest class]]; |
| 66 [order addObject:[CDTypeFormatterUnitTest class]]; |
| 67 |
| 68 NSLog(@"order: %@", order); |
| 69 |
| 70 allTests = [SenTestSuite testSuiteWithName:@"All Tests"]; |
| 71 orderedTests = [SenTestSuite testSuiteWithName:@"Order"]; |
| 72 unorderedTests = [SenTestSuite testSuiteWithName:@"Chaos"]; |
| 73 [allTests addTest:orderedTests]; |
| 74 [allTests addTest:unorderedTests]; |
| 75 |
| 76 // First, set up the tests we want run in a particular order |
| 77 count = [order count]; |
| 78 for (index = 0; index < count; index++) |
| 79 [orderedTests addTest:[SenTestSuite testSuiteForTestCaseClass:[order obj
ectAtIndex:index]]]; |
| 80 |
| 81 // Then search for any tests that we didn't get from the manual setup above |
| 82 { |
| 83 NSMutableSet *used = [NSMutableSet set]; |
| 84 NSArray *allTestCaseSubclasses; |
| 85 |
| 86 [used addObjectsFromArray:order]; |
| 87 [used addObject:self]; |
| 88 [used addObject:[SenInterfaceTestCase class]]; // Dunno why it's picking
this up, skip it. |
| 89 |
| 90 allTestCaseSubclasses = [SenTestCase senAllSubclasses]; |
| 91 count = [allTestCaseSubclasses count]; |
| 92 for (index = 0; index < count; index++) { |
| 93 id aClass; |
| 94 |
| 95 aClass = [allTestCaseSubclasses objectAtIndex:index]; |
| 96 if ([used containsObject:aClass] == NO) { |
| 97 //[unorderedTests addTest:[SenTestSuite testSuiteForTestCaseClas
s:aClass]]; |
| 98 [unorderedTests addTest:[aClass defaultTestSuite]]; |
| 99 [used addObject:aClass]; |
| 100 } |
| 101 } |
| 102 } |
| 103 |
| 104 return allTests; |
| 105 } |
| 106 |
| 107 @end |
OLD | NEW |