Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 245 Vote(s) - 3.4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unit Tests are always "successful" after adding OCMock

#1
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][1] 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?


[1]:

[To see links please register here]

Reply

#2
It turns out I was [missing a *Copy Files* build phase][1] for the framework, which apparently may lead to [a variety of issues][2].

This works for me:

1. Add a *Copy Files* phase to the unit test target's build phases. I positioned it right before the *Run Script* phase, making it the second-to-last one.
2. Drag the *OCMock.framework* item from the project navigator onto the phase in order to add it; adding it using the `+` button doesn't work in Xcode 4.6 (maybe because frameworks are directories?).
3. Set the phase's destination to "Frameworks".
4. In the unit test target's build settings, look for *Runpath Search Paths* and add the entry `@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.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through