Are OCMock and Nocilla incompatible?

331 Views Asked by At

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?

2

There are 2 best solutions below

1
On BEST ANSWER

OCMock does define a macro named andReturn, which has one argument. If Nocilla also uses something called andReturn that has a single argument then that's an incompatibility. As mentioned above, it can be avoided by undefining the andReturn macro from OCMock. This obviously means that it's not possible to use that part of OCMock's syntax afterwards.

0
On

You can use both by using standard square bracket notation, e.g.:

[stubRequest(@"GET", myURL) andReturn](200).withBody(body);

Ugly, but it works.