使用 Hamcrest 断言在 Xcode 3.2.4、iOS 4.1 SDK 上进行单元测试失败
我们使用 iOS 4.1 SDK 升级到 Xcode 3.2.4,现在我们的测试失败了。
首先,由于处理命令输出时发生内部错误:-[XCBuildLogCommandInitationSectionRecorder endMarker]:无法识别的选择器发送到实例0x201aa7200,然后我们使用了苹果论坛建议的补丁(http://gist.github.com)。 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 上完美运行。
We upgraded to Xcode 3.2.4 with iOS 4.1 SDK, now our tests are failing.
First because of this An internal error occurred when handling command output: -[XCBuildLogCommandInvocationSectionRecorder endMarker]: unrecognized selector sent to instance 0x201aa7200 then we used the patch suggested by apple forums (http://gist.github.com/586296) and now the test fail on the first Hamcrest assertion.
NSNumber * c1 = ...
NSNumber * c2 = ...
assertThat(c1, is(c2))
Here's the log:
-[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).
Any one see that before? it was working perfectly on 3.1.3 SDK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用最新的 OCHamcrest 作为静态库而不是框架并将 -lstdc++ 添加到其他链接器标志,可以修复此问题。
希望能节省某人的时间。
This is fixed, by using the latest OCHamcrest as a static library instead of a framework and add -lstdc++ to other linker flags.
Hope that save someone time.