OCMock offers a nice syntax to mock class methods, but can class method calls be forwarded to the real class object?
self.connectionMock = [OCMockObject mockForClass:NSURLConnection.class];
[[[[self.connectionMock stub] andDo:^(NSInvocation *invocation) {
NSURL *url = [invocation getArgumentAtIndexAsObject:2];
NSLog(@"Passing through mock: %@", url);
} ] andForwardToRealObject] connectionWithRequest:OCMOCK_ANY delegate:OCMOCK_ANY];
The problem is andForwardToRealObject
only works for partials. I could do the method swizzling myself, but is there an easy way for me to call the original class method using OCMock?