编译失败时防止运行 OCUnit 测试
我正在使用 Xcode 3.2.2 和内置的 OCUnit 测试内容。我遇到的一个问题是,每次构建时,即使构建失败,我的单元测试都会运行。假设我在一项测试中犯了语法错误。测试无法编译,并运行单元测试的最后一次成功编译。如果依赖目标之一无法构建,也会发生同样的事情 - 测试仍在运行。这显然不是我想要的。
如果构建失败,如何防止测试运行?如果这是不可能的,那么我宁愿让测试永远不会自动运行,这可能吗?抱歉,如果这很明显,我是 Xcode 菜鸟。我应该使用更好的单元测试框架吗?
I'm using Xcode 3.2.2 and the built in OCUnit test stuff. One problem I'm running into is that every time I do a build my unit tests are run, even if the build failed. Let's say I make a syntax error in one of my tests. The test fails to compile and the last successful compilation of the unit tests are run. The same thing happens if one of the dependent targets fail to build - the tests are still run. Which is obviously not what I want.
How can I prevent the tests from running if the build fails? If this is not possible then I'd rather have the tests never run automatically, is that possible? Sorry if this is obvious, I'm an Xcode noob. Should I be using a better unit testing framework?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是转储 OCUnit 并使用 GHUnit,这大约要好一百万倍:
http://github.com/gabriel/gh-unit
The answer is to dump OCUnit and use GHUnit which is about a million times better:
http://github.com/gabriel/gh-unit
您需要做的就是使运行单元测试的脚本依赖于已构建的测试包。为此:
在“目标”组中展开单元测试包并获取有关运行脚本的信息。
在常规选项卡上,单击输入文件的 + 按钮并输入:
All you need to do is make the script that runs the unit tests dependent on your test bundle having been built. To do this:
In your Targets group expand your unit test bundle and Get Info on the Run Script.
On the general tab click the + button for the Input Files and enter: