XCTAssertThrows在断点处停止 [英] XCTAssertThrows stops at breakpoint

查看:108
本文介绍了XCTAssertThrows在断点处停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一种测试方法,我希望在某些条件下SUT引发异常.代码如下:

I'm writing a test method where I want the SUT to throw an exception when under certain conditions. The code looks like this:

- (void) testCantStartTwice
{
    XCTAssertThrows([self.sut start], @"");
}

现在,一切都很好,测试通过了.但是,我为Xcode设置了所有ObjC异常的异常断点,这在调试器中测试应用程序时非常有用.与您现在一样,现在当我使用⌘U执行测试套件时,即使它说"Test Succeeded"(测试成功),它也会在该测试处停止并看起来是否失败.

Now, all is good and the test passes. However, I have Xcode set an Exception Breakpoint for all ObjC exceptions, which is pretty useful when testing out an app in the debugger. As you now, now when I execute my test suite with ⌘U, now it stops at that test and looks like if it's failing, even though it says "Test Succeeded".

有什么方法可以使断点不停止?

Any way of making the breakpoint not stop at that test?

非常感谢

推荐答案

在测试时,也许可以使用测试失败断点而不是异常断点. 2013年的wwdc单元测试视频概述了一个很好的工作流,用于检查测试失败.它基本上说:

Perhaps you could use a Test Failure Breakpoint instead of an Exception breakpoint when you are testing. The wwdc 2013 video on unit testing outlined a pretty good workflow for inspecting test failures. It essentially said:

  1. 设置一个测试失败断点,使您可以检查导致失败的条件.
  2. 如果需要,请在测试的早期设置一个手动断点,然后重新运行,以便您可以像往常一样逐步处理导致失败的语句.

这并不是一个直接的答案,但是据我所知,我不认为有一种方法可以为异常断点创建异常.希望对您有帮助

This isn't really a direct answer, but as far as I know, I don't think there is a way to create exceptions to the exception breakpoint. Hope it helps

这篇关于XCTAssertThrows在断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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