我正在尝试做这样的事情:
id synchronizerDelegate = [OCMockObject mockForProtocol:@protocol(SynchronizerDelegate)];
BOOL isRespondsToSelector = NO;
[[[synchronizerDelegate stub] andReturnValue:OCMOCK_VALUE(isRespondsToSelector)] respondsToSelector:@selector(didLoadFullImage:)];
GHAssertFalse([synchronizerDelegate respondsToSelector:@selector(didLoadFullImage:)], nil);
这是 SynchronizerDelegate 的定义
@protocol SynchronizerDelegate <NSObject>
- (void)didLoadFullImage:(NSData *)data;
@end
但是这个测试用例总是失败(返回值为 YES)。
之前有人尝试过存根“respondsToSelector”方法吗?