Skip to content

Instantly share code, notes, and snippets.

@jballanc
Created June 9, 2013 13:26
Show Gist options
  • Save jballanc/5743530 to your computer and use it in GitHub Desktop.
Save jballanc/5743530 to your computer and use it in GitHub Desktop.
Add this to your SenTestCase subclass to name your tests something other than "test..." (in this case "benchmark...", but you can make it whatever you like by changing the "strncmp" line).
+ (NSArray *)testInvocations {
unsigned int methodCount;
Method *methods = class_copyMethodList(self, &methodCount);
assert(methodCount);
Method method;
SEL methodName;
NSMethodSignature *methodSig;
NSMutableArray *invocations = [[NSMutableArray alloc] init];
NSInvocation *invocation;
do {
method = methods[--methodCount];
methodName = method_getName(method);
if(!strncmp("benchmark", sel_getName(methodName), 9)) {
methodSig = [NSMethodSignature signatureWithObjCTypes:method_getTypeEncoding(method)];
invocation = [NSInvocation invocationWithMethodSignature:methodSig];
[invocation setSelector:methodName];
[invocations addObject:invocation];
}
} while(methodCount);
return invocations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment