1

我目前正在使用 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 一般工作得更好还是满足我的特定需求?

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

4

2 回答 2

1

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

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

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

于 2010-10-27T13:47:18.413 回答
0

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.

于 2010-10-28T18:03:14.653 回答