erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

OCMStub mocking a class method not working #306

Closed marcuswu0814 closed 8 years ago

marcuswu0814 commented 8 years ago

I try to mocking a class method like this:

id classMock = OCMClassMock([NSString class]);
OCMStub([classMock string]).andReturn(@"123456");
NSString *aString = [NSString string];
NSLog(@"%@", aString);

But the aString is not "123456", anything wrong when I used it?

marcuswu0814 commented 8 years ago

Sorry, I think I do it in wrong way.

I read the doc write: _Class methods on NSString and NSArray cannot be stubbed or verified_ Please help me to close this issue, thanks.