Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bugfix for SenTestCase when using base classes for test cases.
// OCUnit/SenTestCase's vanilla testInvocations method does not produce a unique list of methods
// when you inherit from a common test base class. Currently it will call the same test methods
// multiple times, depending on the number of base classes.
//
// To prevent these duplicate test method calls, override testInvocations like this.
//
// Written in 2012 by Torsten Becker <torsten.becker@gmail.com>
@interface BetterTestCase : SenTestCase
@end
@implementation BetterTestCase
+ (NSArray *)testInvocations
{
NSArray *invocations = [super testInvocations];
NSMutableDictionary *selectorsToInvocations = [[NSMutableDictionary alloc] init];
for (NSInvocation *invoc in invocations)
{
[selectorsToInvocations setObject:invoc forKey:[NSString stringWithUTF8String:sel_getName(invoc.selector)]];
}
return [selectorsToInvocations allValues];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.