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

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

问题描述

我正在尝试将 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];
}

一切正常,构建成功.如果我取消 hello 调用,如下所示:

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).

当没有调用预期的方法时,这 crash 正常吗?是不是我的配置不好?

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

推荐答案

你没有配置不好,这是苹果在发布iOS4时在模拟器SDK中引入的一个bug.基本上,如果使用 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

不幸的是,这个错误影响了 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).

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

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