3

I´m getting a crash on OCMockito, when calling methods from a mock object. Only using OCMockito-1.2.0

Basically, what i´m doing is: Include the OCHamcrestIOS.framework and OCMockitoIOS.framework . In the frameworks folder. Also check the copy if needed checkpoint.

Then i´m my test code I do the more simple test ever:

  - (void)testUsingNumbers
  {
   //  assertThatInt(42, is(@42));
  // assertThatUnsignedShort(6 * 9, isNot(@42U));

   NSArray *mockArray = mock([NSArray class]);

   // stubbing
   [given([mockArray objectAtIndex:0]) willReturn:@"first"];

   // following prints "(null)" because objectAtIndex:999 was not stubbed
   NSLog(@"%@", [mockArray objectAtIndex:999]);
} 

And the test crash due a failure not in the test but in the call to the mock object. This is the console message:

[NSInvocation mkt_arrayArguments]: unrecognized selector sent to instance 0x2864db0
<unknown>:0: error: -[ExampleTests testUsingNumbers] : -[NSInvocation mkt_arrayArguments]: unrecognized selector sent to instance 0x2864db0
(
    0   CoreFoundation    0x00b1d5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib   0x007958b6 objc_exception_throw + 44
    2   CoreFoundation    0x00bba903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation    0x00b0d90b ___forwarding___ + 1019
    4   CoreFoundation    0x00b0d4ee _CF_forwarding_prep_0 + 14
    5   ExampleTests      0x0279107a -[MKTInvocationMatcher setExpectedInvocation:] + 303
    6   ExampleTests      0x027901f9 -[MKTInvocationContainer setInvocationForPotentialStubbing:] + 150
    7   ExampleTests      0x0279251d -[MKTBaseMockObject prepareInvocationForStubbing:] + 52
    8   ExampleTests      0x027921b9 -[MKTBaseMockObject forwardInvocation:] + 79
    9   CoreFoundation    0x00b0d6da ___forwarding___ + 458
    10  CoreFoundation    0x00b0d4ee _CF_forwarding_prep_0 + 14

)

I´ve performed 3 different ways of installation, but even the examples in the source project are crashing. The framework used to work fine in previos versions of xcode and mac OS. Currently I´m in xcode 5.1.1 and Mac os 10.9.2

supersabbath
  • 364
  • 3
  • 8
  • This question lacks sufficient information to diagnose the problem. Please include the [relevant parts of the code](http://stackoverflow.com/help/mcve) and explain what you're trying to accomplish and how your results differ from the desired results. Please read this [advice on asking good questions](http://stackoverflow.com/help/how-to-ask) and this blog post [Writing the perfect question](http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx). Pay special attention to the "Golden Rule", though I highly advise you to read the entire article. – Adi Inbar Apr 15 '14 at 20:43

0 Answers0