【发布时间】:2016-02-16 11:03:21
【问题描述】:
我正在对一个自定义UITableviewCell(TrasmitCell) 数据进行单元测试,我们在UITableviewCell、textLabel 和 DetailTextLabel 中有内置标签,而不是我创建了一个自定义单元格并显示在我的表格视图中。现在我想测试传递给该自定义单元格的数据。我能够获得内置方法 textLabel 和 DetailTextLabel 但我如何获得自定义单元格(TrasmitCell) 的内容。自定义单元格(TrasmitCell) 有两个标签和一个图像
- (void)testTableViewCellsHaveCorrectTextLabel {
NSIndexPath *rowIndex0 = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell *cell0 = [self.viewControllerUnderTest tableView:self.viewControllerUnderTest.tableView cellForRowAtIndexPath:rowIndex0];
XCTAssert([cell0.textLabel.text isEqualToString:@"abc"], @"ViewController under test is composed of a UITableView that has improperly initialized UITableViewCells");
//Instead of cell0.textLabel.text m looking for data from custom tableview cell objects
}
【问题讨论】:
标签: ios objective-c uitableview unit-testing