I am using OCMock (version 3.1.1) in my project and I am trying to use the OCMVerify macro to check if some method is called inside my object.
The problem is when I put this line:
OCMVerify([mockEngine notify]);
XCode show me the following link error (I've tried all platforms though):
Undefined symbols for architecture i386:
"OCMMakeLocation(objc_object*, char const*, int)", referenced from:
-[T009_EngineTest testPostEvent] in T009_EngineTest.o
ld: symbol(s) not found for architecture i386
I took the last version of the library from the website and I've also tried to compile it by myself.
Here is the unit test code:
Engine *mockEngine = OCMClassMock([Engine class]);
Object *obj = [[Object alloc] init];
[mockEngine startUp];
[mockEngine run];
[mockEngine postEvent:obj];
[NSThread sleepForTimeInterval:0.5];
OCMVerify([mockEngine notify]); // << THIS LINE CREATES THE LINK PROBLEM..
[mockEngine shutDown];
If I comment that line, the compiler links successfully.. It seems that that symbol is not in the library binary but I checked it was in the Xcode Compile Sources list. Then I did a workaround... I hardcoded this line (the original code from the OCMock) into my unit test file:
OCMLocation *OCMMakeLocation(id testCase, const char *fileCString, int line){
return [OCMLocation locationWithTestCase:testCase file:[NSString stringWithUTF8String:fileCString] line:line];
}
And it works! Now I want to know if there is some bug in OCMock or am I doing something wrong!
Here is the original header file declaring the external OCMakeLocation function: https://github.com/erikdoe/ocmock/blob/master/Source/OCMock/OCMLocation.h and here its implementation: https://github.com/erikdoe/ocmock/blob/master/Source/OCMock/OCMLocation.m
Thanks.