How does unit testing on the iPhone work?

雨燕双飞 提交于 2019-12-18 12:29:35

问题


Do I need special libraries for this, or can I just create a huge class that trys to instantiate every object of my project and test all the methods in there? How's that done in theory?


回答1:


If you're targeting iPhone OS 2.2 or later, you can use the version of OCUnit that's bundled with Xcode. There's a good blog article by Kailoa Kadano about this on Mobile Orchard. OCUnit is a unit testing framework that's similar to the well known JUnit framework from the Java world.

You can always do "poor man's unit testing" by creating a simple test program that uses the assert() macro in the C header assert.h or the NSAssert() macros in Cocoa/Cocoa-touch. That's not a horrible way to get started doing unit testing, but I'd really recommend looking at OCUnit or another unit testing framework eventually.

Which ever way you structure your unit tests, you'll want to create a separate target in your Xcode project to build and run the tests.




回答2:


Googling "unit testing iPhone" gives this excellent link as the first hit:

To sum up, Google Toolbox provides a good infrastructure for unit testing on iPhone.




回答3:


GHUnit is awesome.




回答4:


I really love Kiwi: BDD (RSpec) for iPhone & iPad.

For a comprehensive answer, check out iOS Tests/Specs TDD/BDD and Integration & Acceptance Testing.



来源:https://stackoverflow.com/questions/862244/how-does-unit-testing-on-the-iphone-work

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