How to use mock and verify methods of OCMock in objective-C ? Is there any good tutorial on OCMock is available on the internet?
My problem is I am getting an error:
OCMckObject[NSNumberFormatter]: expected method was not invoked:setAllowsFloats:YES
I have written following Code:
- (void) testReturnStringFromNumber
{
id mockFormatter = [OCMockObject mockForClass:[NSNumberFormatter class]];
StringNumber *testObject = [[StringNumber alloc] init];
[[mockFormatter expect] setAllowsFloats:YES];
[testObject returnStringFromNumber:80.23456];
[mockFormatter verify];
}
@implementation StringNumber
- (NSString *) returnStringFromNumber:(float)num
{
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setAllowsFloats:YES];
NSString *str= [formatter stringFromNumber:[NSNumber numberWithFloat:num]];
[formatter release];
return str;
}
@end
Hi Sanjeev
I don't know anything about this and I'm out of town this weekend (at the Napa Valley Marathon). If nobody else replies, I'll look at this next week.
Hi Sanjeev
I've had a little google into this matter. There is an on-line tutorial available at:
http://www.mulle-kybernetik.com/software/OCMock/
And I believe you can contact the author of the framework (directly or via a mailing list).