3

从模拟对象调用方法时,我在 OCMockito 上崩溃了。仅使用 OCMockito-1.2.0

基本上,我正在做的是:包括 OCHamcrestIOS.framework 和 OCMockitoIOS.framework 。在框架文件夹中。如果需要检查点,还要检查副本。

然后我是我的测试代码,我做了更简单的测试:

  - (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]);
} 

并且测试崩溃不是由于测试失败而是在对模拟对象的调用中失败。这是控制台消息:

[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

)

我已经执行了 3 种不同的安装方式,但即使是源项目中的示例也崩溃了。该框架曾经在 xcode 和 mac OS 的早期版本中运行良好。目前我在 xcode 5.1.1 和 Mac os 10.9.2

4

0 回答 0