【发布时间】:2010-07-08 15:51:49
【问题描述】:
单元测试视图控制器似乎是 iPhone 开发中非常重要的一部分 (see this Article)。然而,这需要从 Nib 初始化控制器,我发现在逻辑测试中无法正确完成。
在逻辑测试中从 Bundle (see this Question) 加载资源工作正常。甚至可以像这样加载 Nib:
UntitledViewController* controller = [[UntitledViewController alloc]initWithNibName:nil bundle:[NSBundle bundleForClass:[self class]]];
。然而,它只有在 nib 只包含 UIViews 时才有效。其他视图(我尝试了 UITableView 和 UISwitch)导致 otest 失败,代码为 138。
是否可以使用逻辑测试来测试我的 Nib,如果可以,如何?
【问题讨论】:
标签: objective-c iphone unit-testing octest