The OCMockito documentation claims that it's possible to make fun of class objects , but I'm damned if I can how to do this. The following test failed Expected "Purple" but was "":
- (void)testClassMethodMocking
{
Class stringClassMock = mockClass([NSString class]);
[given([stringClassMock string]) willReturn:@"Purple"];
assertThat([NSString string], equalTo(@"Purple"));
}
If the answer to the section with frequently asked questions is "How do you mock a class object?" doesn't mean it's possible to stub the return value of a class method, what is it used for?
EDIT:
Of course, the above is a degenerate example, the real call [NSString string] is inside the test method:
- (NSString *)methodThatCallsAClassMethod
{
return [NSString string];
}
... to make the statement above:
assertThat([testedObject methodThatCallsAClassMethod], equalTo(@"Purple"));
So the above just doesn't work? How then can I achieve what I want to do?