1

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?

Ravi Desai
  • 461
  • 4
  • 12
  • It is also possible to "fix" the error by placing a `#undef andReturn` in-between importing OCMock and Nocilla. Which would indicate a possible incompatibility in the two libraries. – Ravi Desai Oct 14 '14 at 13:47

2 Answers2

5

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.

Erik Doernenburg
  • 2,933
  • 18
  • 21
  • I agree. I was just surprised by the incompatibility since I saw so many examples of people using the libraries at the same time. It's an unfortunate side effect of using macros to implement your behavior I guess, but I understand why both libraries did it. – Ravi Desai Nov 25 '14 at 13:48
0

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

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

Ugly, but it works.

Chris Vig
  • 8,552
  • 2
  • 27
  • 35