I am trying to use both OCMock and Nocilla in the same set of unit tests. I used CocoaPods to install them both, and reference them using
#import <OCMock/OCMock.h>
#import <Nocilla/Nocilla.h>
But when I try to use Nocilla's .andReturn in the following way (where subscriptionData is an NSData *):
stubRequest(@"GET", @"https://api.test.com/api/beaconinbox/subscriptions/list").andReturn(200).withBody(subscriptionData);
I get a compiler error that looks like this:
/Users/ravi/GitHub/Mobile/ClinicalInbox/ClinicalInboxTests/ClinicalInboxTests.m:63:93: Property '_andReturn' not found on object of type 'LSStubRequestDSL *'
Which persists until I remove the #import "<OCMock/OCMock.h>"
from my code. Then all my tests run perfectly.
Is there a known incompatibility with OCMock and Nocilla? I couldn't seem to find one anywhere - in fact I've seen just the opposite - many examples of people using both in the same test framework all the time. So I must assume I'm doing something wrong, can anyone tell me what?
OCMock does define a macro named
andReturn
, which has one argument. If Nocilla also uses something calledandReturn
that has a single argument then that's an incompatibility. As mentioned above, it can be avoided by undefining theandReturn
macro from OCMock. This obviously means that it's not possible to use that part of OCMock's syntax afterwards.