biz code:
- Code: Select all
#import "MyTestClass.h"
@implementation MyBizClass
- (void)testMethod {
MyTestClass *testClass = [[MyTestClass alloc] init];
NSString *result = [testClass test];
NSLog( result ); // this biz code will return @"test", I want to mock this method, and return something else.
}
@end
When I write test code, I want to mock the method 'test' of class 'MyTestClass', if I do the following, it not work:
- Code: Select all
#import "MyTestClass.h"
#import "MyBizClass.h"
-(vod)testClass {
id mockClass = OCMClassMock( [ MyTestClass class] );
OCMStub( [ mockClass test ] ).andReturn( @"here is mock method" );
}