关于使用 OCUnit 进行 iPhone 单元测试入门的好教程是什么?
我试图让 OCUnit 对我的项目做任何事情,但我失败了:-( 有没有什么好的教程可以让它工作?我发现的所有内容都讲述了不同的内容,而且它们都非常复杂...
我尝试的是
- 设置一个单元测试目标,
- 将我的目标添加为依赖项,
- 将 xxTest.m 添加到我的单元目标并编写一个测试用例,例如:
代码:
#import <SenTestingKit/SenTestingKit.h>
@interface XTest : SenTestCase {
}
@end
@implementation XTest
- (void)testAuthentication {
STFail(@"fail");
}
@end
结果是构建成功......我需要做什么才能使单元测试正常工作?
I am trying to get OCUnit to do anything on my project, but I am failing :-(
Is there any good tutorial out there to get it work? Everything I find tells something different and they are all pretty complicated ...
What I tried is e.g.
- set up a Unit Testing Target
- add my Target as dependency
- add a xxTest.m to my unit target and write a testcase like:
code:
#import <SenTestingKit/SenTestingKit.h>
@interface XTest : SenTestCase {
}
@end
@implementation XTest
- (void)testAuthentication {
STFail(@"fail");
}
@end
The result is, a build success ... What do I have to do to get unit testing working ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 iTunes U。 上学期的“单元测试”课程视频class 也对此进行了详细研究。
我上学期单元测试的课程笔记可以在这里找到。我创建了一个小型示例应用程序来说明单元测试的使用,源代码可从 这里。
我还强烈推荐 iDeveloper.tv 上的 Graham Lee 关于 Cocoa 测试驱动开发的课程。您确实需要为这些视频付费,但鉴于其中提供的材料的质量,它们非常值得。我从观看他们的过程中学到了很多技巧。
I demonstrate the setup of unit tests, along with the new UI Automation interface testing instrument, in the video for the "Testing" class session in my iPhone development class on iTunes U. The video for the "Unit testing" session from last semester's class also delves into this in detail.
My course notes for unit testing from last semesters session can be found here. I created a small sample application illustrating the use of unit tests, with the source code available for download from here.
I also highly recommend Graham Lee's course on test-driven development for Cocoa on iDeveloper.tv. You do have to pay for those videos, but they are well worth the cost for the quality of the material presented there. I picked up a lot of techniques from watching them.
之前已经问过这个问题:什么是单元测试 Objective-C 代码的最佳方法?
您需要的所有信息都可以在这里找到:http://developer.apple.com/tools/unittest.html
Google 为 iPhone 开发人员提供了一个有用的代码库,其中还包括一个替代测试框架。有些人比 Xcode 中包含的 OCUnit 更喜欢它:http ://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting
This question has been asked before: What is the best way to unit test Objective-C code?
All of the information you need can be found here: http://developer.apple.com/tools/unittest.html
Google provides a library of useful code for iPhone developers which also includes an alternative testing framework. Some like it better than the OCUnit that is included with Xcode: http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting