测试视图控制器——iPhone
我的问题有两个方面。1.我可以使用OCUnit测试视图控制器吗。如果是,我应该怎么做?如果没有,我还可以使用其他测试工具吗?你当然可以。假设您有一个UITableViewController,您希望确保它有2个分区,每个分区有5行;这在测试方法中很容易做到,如:测试视图控制器——iPhone,iphone,objective-c,ocunit,Iphone,Objective C,Ocunit,我的问题有两个方面。1.我可以使用OCUnit测试视图控制器吗。如果是,我应该怎么做?如果没有,我还可以使用其他测试工具吗?你当然可以。假设您有一个UITableViewController,您希望确保它有2个分区,每个分区有5行;这在测试方法中很容易做到,如: - (void) testTableHasCorrectRowsAndSections { id tableViewController = [[[YourTableViewControllerSubclass alloc] ini
- (void) testTableHasCorrectRowsAndSections
{
id tableViewController = [[[YourTableViewControllerSubclass alloc] init] autorelease];
STAssertEquals(2,[tableViewController numberOfSectionsInTableView:nil],@"");
STAssertEquals(5,[tableViewController tableView:nil numberOfRowsInSection:0],@"");
STAssertEquals(5,[tableViewController tableView:nil numberOfRowsInSection:1],@"");
}
我还建议您利用它来帮助您测试控制器。您可以轻松地模拟视图,并确保控制器与视图正确交互