单元测试失败在Xcode 3.2.4,iOS 4.1 SDK使用Hamcrest断言

时间:2010-09-30 22:16:29

标签: iphone xcode hamcrest

我们使用iOS 4.1 SDK升级到Xcode 3.2.4,现在我们的测试失败了。

首先是因为这个处理命令输出时出现内部错误: - [XCBuildLogCommandInvocationSectionRecorder endMarker]:无法识别的选择器发送到实例0x201aa7200 然后我们使用了apple forums建议的补丁(http:// gist .github.com / 586296)现在测试在第一次Hamcrest断言上失败了。

NSNumber * c1 = ...
NSNumber * c2 = ...
assertThat(c1, is(c2))

这是日志:

-[NSCFNumber conformsToProtocol:]: unrecognized selector sent to instance 0x2116890
2010-09-30 22:10:23.153 otest[21063:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber conformsToProtocol:]: unrecognized selector sent to instance 0x2116890'
*** Call stack at first throw:
(
 0   CoreFoundation                      0x004e3b99 __exceptionPreprocess + 185
 1   libobjc.A.dylib                     0x002d840e objc_exception_throw + 47
 2   CoreFoundation                      0x004e56ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
 3   CoreFoundation                      0x004552b6 ___forwarding___ + 966
 4   CoreFoundation                      0x00454e72 _CF_forwarding_prep_0 + 50
 5   OCHamcrest                          0x00ccd17b HC_wrapInMatcher + 52
 6   OCHamcrest                          0x00ccb4e1 HC_is + 41
 7   UnitTests                           0x030870c9 -[MyTest testMethod] + 141
 8   CoreFoundation                      0x004545cd __invoking___ + 29
 9   CoreFoundation                      0x004544a1 -[NSInvocation invoke] + 145
 10  SenTestingKit                       0x2010464a -[SenTestCase invokeTest] + 69
 11  SenTestingKit                       0x20104d1f -[SenTestCase performTest:] + 192
 12  SenTestingKit                       0x2010444b -[SenTest run] + 88
 13  SenTestingKit                       0x20106fa7 -[SenTestSuite performTest:] + 115
 14  SenTestingKit                       0x2010444b -[SenTest run] + 88
 15  SenTestingKit                       0x20106fa7 -[SenTestSuite performTest:] + 115
 16  SenTestingKit                       0x2010444b -[SenTest run] + 88
 17  SenTestingKit                       0x20106871 +[SenTestProbe runTests:] + 174
 18  otest                               0x000023b3 0x0 + 9139
 19  otest                               0x000025de 0x0 + 9694
 20  otest                               0x00002086 0x0 + 8326
 21  otest                               0x00002035 0x0 + 8245
 22  ???                                 0x00000003 0x0 + 3
)
terminate called after throwing an instance of 'NSException'
/Developer/Xcode3.2.4/Tools/RunPlatformUnitTests.include: line 415: 21063 Abort trap              "${THIN_TEST_RIG}" "${OTHER_TEST_FLAGS}" "${TEST_BUNDLE_PATH}"
/Developer/Xcode3.2.4/Tools/RunPlatformUnitTests.include:451: error: Test rig '/Developer/Xcode3.2.4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/Developer/usr/bin/otest' exited abnormally with code 134 (it may have crashed).

之前有人看过吗?它在3.1.3 SDK上完美运行。

1 个答案:

答案 0 :(得分:1)

通过使用最新的OCHamcrest作为静态库而不是框架并将-lstdc ++添加到其他链接器标志来解决这个问题。

希望节省一些时间。