【发布时间】:2013-06-27 15:00:36
【问题描述】:
我有以下代码来测试视图是否正确配置(其中,我将monthScrollview 放置为视图的子视图:
@implementation ECBrowserViewControllerTests
-(void)setUp
{
//-deviceSpecific simply adds suffix like '_iPad'
main=[[ECBrowserViewController alloc] initWithNibName:[@"ECBrowserViewController" deviceSpecific] bundle:nil];
}
-(void)testOutlets
{
STAssertNotNil(main.view, @"View outlet not set!");
STAssertNotNil(main.monthScrollView, @"no month scrollview");
STAssertTrue(main.monthScrollView.pagingEnabled, @"Paging should be enabled");
}
-(void)testPaging
{
STAssertNotNil(main.monthScrollView, @"no month scrollview");
STAssertTrue(main.monthScrollView.pagingEnabled, @"Paging should be enabled");
}
@end
谁能告诉我为什么testPaging 失败,而testOutlets 成功?我发现这是先检查 parentView,但为什么呢?
我正在使用 Xcode 4.6.3 和内置 SenTestingKit
【问题讨论】:
-
冒着提出愚蠢问题的风险,
monthScrollView已连接到它的插座,是吗? -
是的。
testOutlets通过。
标签: objective-c xcode unit-testing xib ocunit