iPhone上的单元测试如何工作? [英] How does unit testing on the iPhone work?

查看:109
本文介绍了iPhone上的单元测试如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要特殊的库,或者我可以创建一个巨大的类,实例化我的项目的每个对象,并测试所有的方法在那里?

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?

推荐答案

如果你的目标是iPhone OS 2.2或更高版本,你可以使用OCUnit的版本捆绑Xcode。有Kailoa Kadano的好的博客文章移动果园。 OCUnit是一个单元测试框架,类似于来自Java世界的着名的JUnit框架。

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.

你可以通过创建一个简单的测试程序来做穷人的单元测试它使用C头中的 assert() assert.h NSAssert )宏在Cocoa / Cocoa-touch。这不是一个可怕的方式开始做单元测试,但我真的建议最终看看OCUnit或另一个单元测试框架。

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.

哪种方式你的单元测试测试,您将需要在Xcode项目中创建一个单独的目标来构建和运行测试。

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.

这篇关于iPhone上的单元测试如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆