Created
May 15, 2012 08:50
-
-
Save torsten/2700140 to your computer and use it in GitHub Desktop.
Bugfix for SenTestCase when using base classes for test cases.
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
// 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