使用 SenTestingKit/OCUnit 测试异常
我似乎能够找到的用于测试异常的唯一解决方案是使用 SenTestingKit 的 STAssertThrows 和 STAssertThrowsSpecific,但是在这两种情况下,当引发异常时,测试中的应用程序都会挂起,直到我手动要求它继续。当然,测试框架应该吞掉异常吗?如果没有,是否有人对测试异常有更好的建议?
The only solution I seem to be able to find for testing for exceptions is using SenTestingKit's STAssertThrows and STAssertThrowsSpecific, however in both cases when the exception is thrown the application under test hangs until I manually ask it to continue. Surely the exceptions should be swallowed by the testing framework? And if not, does anyone have a beter suggestion for testing exceptions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我本来打算删除这个问题,但对于其他遇到同样情况的人来说,这是解决方案:
应用程序中断的原因是我设置了异常断点。一旦引发异常,它就会中断,而不是在它冒泡时,所以它实际上在达到我的断言之前就被停止了。当我运行测试时,我只需要关闭断点(或只是异常断点)。
I was going to delete this question, but here is the solution for anyone else who finds themselves in a the same situation:
The reason that the application was breaking was that I had an Exception Breakpoint set up. This breaks as soon as an exception is raised, not when it bubbles up, so it was actually being halted before it had even got as far as my assertion. I just need to toggle off breakpoints (or just the exception breakpoint) when I am running tests.