在iOS 4上通过OCMock验证使用代码134异常退出测试装置 [英] Test rig exited abnormally with code 134 with OCMock verify on iOS 4

查看:120
本文介绍了在iOS 4上通过OCMock验证使用代码134异常退出测试装置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将OCMock添加到我的iOS 4项目中。为了测试它,我有一个类 Person ,有一个方法, -hello 。当我运行此测试时:

I'm trying to add OCMock to my iOS 4 project. To test it out, I have a class Person with one method, -hello. When I run this test:

- (void) testMock {
    id mock = [OCMockObject mockForClass:[Person class]];
    [[mock expect] hello];

    [mock hello];

    [mock verify];
}

一切都很好,构建成功。如果我拿走你好的话,就像这样:

Everything is fine, and the build succeeds. If I take away the hello call, like this:

- (void) testMock {
    id mock = [OCMockObject mockForClass:[Person class]];
    [[mock expect] hello];

    [mock verify];
}

我希望收到一条错误消息,告诉我我的预期方法不是嘲笑模仿。相反,我得到一个关于测试台崩溃的神秘消息:

I'd expect to get an error message telling me that my expected method wasn't called on the mock. Instead I get a cryptic message about the test rig crashing:

/Developer/Tools/RunPlatformUnitTests.include:451:0 Test rig '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/Developer/usr/bin/otest' exited abnormally with code 134 (it may have crashed).

当未调用预期方法时,崩溃是否正常?我的配置是否错误?

Is this crash normal when an expected method isn't called? Do I have a bad configuration?

推荐答案

您的配置不正确,这是Apple在模拟器中引入的错误他们发布iOS4时的SDK。基本上,如果使用NSInvocation对象调用的代码抛出异常,则该异常是无法捕获的。我第一次看到这个问题的时候写了这个问题:

You don't have a bad configuration, it's a bug that Apple introduced in the simulator SDK when they released iOS4. Basically, if code invoked using an NSInvocation object throws an exception, then that exception is uncatchable. I wrote about the issue when it first appeared here:

http://pivotallabs.com/users/adam/blog/articles/1302-objective-c-exceptions -thrown-inside-methods-invoked-via-nsinvocation-are-uncatchable

不幸的是,这个bug影响了OCMock,而Apple并没有表现出太大的兴趣。修理它。很多人都提交了错误报告,但无济于事。

Unfortunately, this bug affects OCMock and Apple hasn't show much interest in fixing it. Many people have filed bug reports, but to no avail.

我意识到这不太舒服,但是当你使用 Cedar 进行测试(我相信 GTM )。

I realize this is little comfort, but you will get slightly better error messages when using Cedar for testing (I believe the same is true for GTM).

这篇关于在iOS 4上通过OCMock验证使用代码134异常退出测试装置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆