Created
June 9, 2013 13:26
-
-
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).
This file contains 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
+ (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