Created
October 9, 2013 08:47
-
-
Save fjolnir/6898241 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)_testRecordingAtPath:(NSString *)aPath | |
{ | |
XCTAssert(YES,@"foo"); | |
} | |
+ (NSArray *)testInvocations | |
{ | |
NSMutableArray *invocations = [[super testInvocations] mutableCopy]; | |
NSArray * const aiff = [[NSBundle bundleForClass:self] pathsForResourcesOfType:@"aiff" inDirectory:@"Recordings"]; | |
NSArray * const wave = [[NSBundle bundleForClass:self] pathsForResourcesOfType:@"wav" inDirectory:@"Recordings"]; | |
NSArray * const recordings = [aiff arrayByAddingObjectsFromArray:wave]; | |
for(NSString *path in recordings) { | |
SEL selector = NSSelectorFromString(NSFormat(@"_test%@", [[[path lastPathComponent] stringByDeletingPathExtension] capitalizedString])); | |
if(![self instancesRespondToSelector:selector]) { | |
IMP imp = imp_implementationWithBlock(^(id self, SEL _cmd){ | |
[self _testRecordingAtPath:path]; | |
}); | |
NSAssert(class_addMethod(self, selector, imp, "v@:"), @"Failed to create test for: %@", [[path lastPathComponent] stringByDeletingPathExtension]); | |
} | |
NSMethodSignature *sig = [self instanceMethodSignatureForSelector:selector]; | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig]; | |
invocation.selector = selector; | |
[invocations addObject:invocation]; | |
} | |
return invocations; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment