I would like to use OCMock in my Cocoa project's unit tests. I have downloaded the latest version of OCMock (2.0.1) and copied the OCMock.framework into my project's directory. In Xcode, I have added the framework to the unit test target's link phase. I have then added some code that uses OCMock's classes.
From then on out, all unit tests are reported as "successful" - green light, no errors or warnings. Even after introducing STFail
calls, Xcode claims "Test succeeded". Placing a breakpoint in arbitrary test methods reveals that none of them are executed.
The issue persists if I comment out the code using OCMock, including the import
directives.
The issue vanishes - i.e., the STFails
start failing again - when I remove OCMock from the link phase.
This is similar to another question I've asked before, but not exactly the same: In this case, the info in the Log Navigator shows no errors. What could be causing this behavior? What can I do to diagnose the matter?
It turns out I was missing a Copy Files build phase for the framework, which apparently may lead to a variety of issues.
This works for me:
+
button doesn't work in Xcode 4.6 (maybe because frameworks are directories?).@loader_path/../Frameworks
.This way, the unit test executable will be able to find the framework at runtime. Note that you can also use "Products Directory" as the destination of the Copy Files phase, in which case you can skip the fourth step.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With