I'm trying to deal with OCMock
. I created simple class MyClass
.
@interface MyClass : NSObject
- (NSString *)simpleMethod;
@end
@implementation MyClass
- (NSString *)simpleMethod {
[self method];
return @"simple";
}
- (void)method {
NSLog(@"ABC");
}
@end
What I want to check is if method method
was invoked when simpleMethod
has been called. Now I've got following code but it doesn't work:
- (void)testMethodInvoked
{
id mock = [OCMockObject mockForClass:[MyClass class]];
[[mock stub] simpleMethod];
SEL selector = NSSelectorFromString(@"method");
[[mock expect] methodForSelector:selector];
[mock verify];
}
How should I test this case? I think that is pretty easy to do, but I have no idea how solve this problem.
How to create mock and call method simpleMethod
which invoke method method
?
Current log:
<unknown>:0: error: -[OCMockTestTests testOne] : OCMockObject[MyClass]: expected method was not invoked: methodForSelector:@selector(method)
method
is private method, not visible outside classMyClass
– Indulgent