Lefora Free Forum
login join
Loading
610 views

How to use mock and verify methods of OCMock in objective-C ? Is there any good tutorial on OCMock is available on the internet?

Page 1
1–3
rookie - member
2 posts

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

?
288 posts

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.

__________________
?
288 posts

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). 

__________________
Page 1
1–3

Locked Topic


You must be a member to post in this forum

Join Now!