How does unit testing on the iPhone work?

2020-02-26 00:56发布

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?

4条回答
狗以群分
2楼-- · 2020-02-26 01:31

GHUnit is awesome.

查看更多
Fickle 薄情
3楼-- · 2020-02-26 01:36

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.

查看更多
劳资没心,怎么记你
4楼-- · 2020-02-26 01:38

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.

查看更多
唯我独甜
5楼-- · 2020-02-26 01:38

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

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

查看更多
登录 后发表回答