I have a pretty simple setup for this unit test. I have a class that has a delegate property:
@interface MyClass : NSObject
...
@property (nonatomic, weak) i
A workaround is to use Partial Mocks.
@interface TestMyDelegateProtocolDelegate : NSObject
@end
@implementation TestMyDelegateProtocolDelegate
- (void)someMethod {}
@end
@implementation SomeTest {
- (void)testMyMethod_WithDelegate {
id delegate = [[TestMyDelegateProtocolDelegate] alloc] init];
id delegateMock = [OCMockObject partialMockForObject:delegate]
[[[delegateMock expect] someMethod]
myClassIvar.connectionDelegate = delegate;
[myClass someOtherMethod];
STAssertNoThrow([delegate verify], @"should have called someMethod on delegate.");
}
@end