Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created October 9, 2013 08:47
Show Gist options
  • Save fjolnir/6898241 to your computer and use it in GitHub Desktop.
Save fjolnir/6898241 to your computer and use it in GitHub Desktop.
- (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