Here is an OCUnit test that simply stubs the method playerID
of GKTurnBasedParticipant
:
#import <GameKit/GameKit.h>
#import "OnlineMatchTest.h"
#import "OCMock.h"
@implementation OnlineMatchTest
- (void)setUp {
GKTurnBasedParticipant *participant = [OCMockObject mockForClass:[GKTurnBasedParticipant class]];
[[[(id)participant stub] andReturn:@"123"] playerID];
}
- (void)test {
// Do nothing.
}
@end
However, the test fails as if the method -[GKTurnBasedParticipant playerID]
did not exist:
Test Case '-[OnlineMatchTest test]' started.
Unknown.m:0: error: -[OnlineMatchTest test] : *** -[NSProxy doesNotRecognizeSelector:playerID] called!
Test Case '-[OnlineMatchTest test]' failed (0.000 seconds).
Why is this happening? I am compiling against the iOS 6.1 SDK, so this method should certainly exist.