单元测试和 iPhone 开发

发布于 2024-09-29 22:11:16 字数 778 浏览 9 评论 0原文

我目前正在使用 Xcode 3.2.4 附带的 OCUnit 对我的应用程序进行单元测试。我的工作流程通常是在失败的单元测试中设置一些断点,以便快速检查状态。我正在使用 Apple 的 OCUnit 设置:

http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html

但是上面的设置让我有些头痛。 Apple 区分应用程序测试和逻辑测试。在我看来:

  • 您无法调试逻辑测试。就好像它们在您构建项目时无形地运行一样。

  • 您可以调试应用程序测试,但您必须在设备上运行这些测试,而不是模拟器(原因是什么?)

这意味着在我当前的工作流程中,一切都进展缓慢。有关让应用程序测试在模拟器上运行的任何提示吗?或者有任何指向另一个测试框架的引脚指针吗? 会例如。 google-toolbox-for-mac 总体上效果更好还是满足我的特定需求?

另外,欢迎对在单元测试中使用断点的一般评论! :-)

I'm currently using OCUnit that ships with Xcode 3.2.4 for doing unit testing of my application. My workflow is often to set some break points in a failing unittestin order to quickly inspect the state. I'm using Apple's OCUnit setup:

http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html

but the setup from above gives me some headaches. Apple distinguish between Application tests and Logic tests. As I see it:

  • You cannot debug logic tests. It's as if they're invisibly run when you build your project.

  • You can debug application tests, but you have to run these on the device and not the simulator (what is the reason for this?)

This means that everything moves kind of slowly with my current workflow. Any hints on getting app tests to run on the simulator? Or any pin pointers to another test-framework?
Would eg. google-toolbox-for-mac work better in general or for my specific needs?

Also, general comments on using breakpoints in the unit tests are welcome! :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

混吃等死 2024-10-06 22:11:16

我过去使用过 Google Toolbox 测试设备,它运行良好,它在模拟器和设备上都运行,如果我愿意,我可以调试我的测试。最近,我厌倦了在每个项目中捆绑如此多的代码,并尝试了 Apple 的方式。

我还发现逻辑/应用程序测试分裂得很奇怪,特别是因为我现在找不到任何方法来调试逻辑测试。 (如果您使用的 AVFoundation 的某些部分无法为 Simulator 构建,那么您显然完全无法进行逻辑测试,这看起来很奇怪。)优点之一是我可以在构建过程中快速运行逻辑测试。

我想这对你没有多大帮助——关键是你可以在 GTM 下调试测试。您可能还想查看此相关问题

I have used the Google Toolbox testing rig in the past and it worked fine, it ran both on the Simulator and the device and I could debug my tests if I wanted to. Recently I got fed up with bundling so much code with each of my projects and tried the Apple way.

I also find the logic/app tests split weird, especially as I can’t find any way to debug the logic tests now. (And if you’re using some parts of AVFoundation that won’t build for Simulator, you are apparently out of luck with logic tests completely, which seems strange.) One of the pros is that I can run the logic tests quickly during build.

I guess this does not help you that much – the point is that you can debug the tests under GTM. And you might also want to check out this related question.

泪痕残 2024-10-06 22:11:16

我知道这并不是一个很好的答案,也不完全对您的事业有帮助。但我一直在使用 NSLog 来运行我的单元测试(如果没有任何输出到控制台,则成功)。当我注释掉我的测试方法时,测试将不会运行。我发现这比 OCUnit 更具可预测性和可靠性。我更愿意使用真正的单元测试器,但是处理 OCUnit 可能发生的常见奇怪错误以及您上面描述的其他缺陷/缺乏功能太令人沮丧了。

I know this isn't really a good answer, nor is it completely helpful to your cause. But I've been using NSLog to run my unit tests (if nothing outputs to the console, then success). When I comment out my tests method then the tests wouldn't run. I found this much more predictable and reliable than OCUnit. I'd much rather use a real true unit tester, but it was too frustrating to deal with the often strange errors that could occur from OCUnit and also the other shortfalls/lack of features you describe above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文