Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>Download OCMock *.** from <a href="http://ocmock.org/#download" rel="nofollow noreferrer">http://ocmock.org/#download</a> (At the moment of this writing 1.77)</li> <li>unpack in a OCMock/ (or another folder) --> You will have two folder "Release" &amp; "Source"</li> <li>Copy the "Release/Library" folder inside your xCode project folder</li> <li>Link your file with xcode dragging all the "Library" folder inside your porject <ul> <li>Select as the target the application TEST target!</li> </ul></li> <li>Go to the "build settings" of your test target <ul> <li>Under "Search Paths" add: +"Header Search Paths" --> insert the path to your OCMock headers(.h) (something like $(PROJECT_DIR)/Library/Headers) +"Library Search Paths" --> insert the path to your OCMock library(.a) (something like $(PROJECT_DIR)/Library/) Note: as path you can also use $(PROJECT_DIR) or $(SRCROOT)/ and select the recursive checkbox to avoid insert the ocmplete path <ul> <li>Under "Linking" add: + "Other Link Flags" --> -all_load</li> </ul></li> </ul></li> </ul> <p>Everything should now work correctly. To verifiy:</p> <pre><code>#import &lt;OCMock/OCMock.h&gt; // simple test to ensure building, linking, // and running test case works in the project - (void)testOCMockPass { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@"mocktest"] lowercaseString]; NSString *returnValue = [mock lowercaseString]; STAssertEqualObjects(@"mocktest", returnValue, @"Should have returned the expected string."); } - (void)testOCMockFail { id mock = [OCMockObject mockForClass:NSString.class]; [[[mock stub] andReturn:@"mocktest"] lowercaseString]; NSString *returnValue = [mock lowercaseString]; STAssertEqualObjects(@"thisIsTheWrongValueToCheck", returnValue, @"Should have returned the expected string."); } </code></pre> <p>Many thanks to: </p> <ul> <li><p><a href="http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-quick-start-guide" rel="nofollow noreferrer">http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-quick-start-guide</a></p></li> <li><p><a href="https://stackoverflow.com/questions/4155690/ocmock-why-do-i-get-an-unrecognized-selector-exception-when-attempting-to-call-a">OCMock: Why do I get an unrecognized selector exception when attempting to call a UIWebView mock?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/5482562/using-ocmock-1-77-for-unit-and-application-test-with-ios4-and-xcode-4-sdk4-3">Using OCMock 1.77 for Unit and Application Test with iOS4 and Xcode 4/SDK4.3</a></p></li> <li><p>Ralph Hoffman for his patience and preocius time</p></li> </ul> <p>Enrico Bottani</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload