- Code: Select all
@implementation MyUnitTest
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state
objects:(id*)stackbuf count:(NSUInteger)len
{
// ...
return someValue;
}
- (void)testSomeFunctionality
{
id mock =
[OCMockObject niceMockForClass:[ClassSupportingFastEnumeration class]];
[(id<NSFastEnumeration>)[[mock stub]
andCall:@selector(countByEnumeratingWithState:objects:count:)
onObject:self]
countByEnumeratingState:OCMOCK_ANY objects:OCMOCK_ANY count:OCMOCK_ANY];
// ...
}
@end
This produces the following compiler warning when defining the stub:
Instance method '-countByEnumeratingState:object:count:' not found (return type defaults to 'id')
And the test fails at run time when defining the stub with the following error:
*** -[NSProxy doesNotRecognizeSelector:countByEnumeratingState:objects:count:] called!
What is the proper way to mock this class?
