メソッドを使用するとき、respondsToSelector:
またはinstancesRespondToSelector:
43 行目で STAssertTrue をバイパスできないのはなぜですか?
//私のテストケースコード
- (void)testApiClass {
//Check object
NSString* classKey = @"Api";
id obj = NSClassFromString(classKey);
STAssertNotNil(obj, [NSString stringWithFormat:@"Model '%@' not found.", classKey]);
//Check properties
NSArray* properties =
@[
@"performSyncRequestWithUri::",
@"performAsyncRequestWithUri:::",
];
for (NSString* property in properties) {
SEL propertySel = NSSelectorFromString(property);
BOOL isRespondsToSel = [obj respondsToSelector:propertySel];
STAssertTrue(isRespondsToSel, [NSString stringWithFormat:@"Property '%@' not found on object of class name '%@'", property, [obj class]]);
}
}
@interface Api : NSObject
- (NSDictionary*)performSyncRequestWithUri:(NSString *)requestUri params:(NSDictionary *)params;
- (void)performAsyncRequestWithUri:(NSString *)requestUri params:(NSDictionary *)params completionHandler:(void (^)(NSDictionary *, NSError *))completionBlock;
@end