How to get started with unit testing in Xcode 4?

偶尔善良 提交于 2019-12-13 12:06:23

问题


Does anyone know how to get started with unit testing in Xcode 4?

How do I create a test and how do I run it?

EDIT: All the Apple documentation is for Xcode 3


回答1:


See this question: Unit testing in XCode 4

Basically, it says to use GHUnit and ignore SenTestingKit for now (bceause it's broken). GHUnit is pretty nifty.




回答2:


Although most of the documentation is in fact for XCode 3, the XCode4 User Guide: Building and Running Your Code gives clear step-by-step instructions. Essentially, you create a Cocoa [Touch] Unit Testing Bundle target and add all your test code to that target. Then add the target to your build scheme. Pretty straightforward (not something I'd say for XCode4 in general...)

I just switched from using GTM (which is what GHUnit uses) and it works fine. The main thing you get from GHUnit is the nifty UI which shows you all the tests and whether they succeeded. The other problems mentioned with OCUnit (such as no debugging) are no longer relevant.




回答3:


I used to say GHUnit, but for XCode 4 specifically I say OCUnit. See my comparison blog post.



来源:https://stackoverflow.com/questions/5389346/how-to-get-started-with-unit-testing-in-xcode-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!