I have a test class created for a custom cell I have created. The cell is fairly complex, has several different labels and images that are auto-layout constrained to the cell's bounds, and I want to test that setting long text for certain labels doesn't make the label go past the bounds of the cell. Essentially, I want to run the following line:
XCTAssertLessThanOrEqual(cell.textLabel!.frame.size.width, cell.frame.size.width, "text label width should be less than cell's frame")
to make sure that my custom textLabel doesn't go past the bounds. The problem I'm having, though, is I don't know how to mock the custom cell, cell above. Do I need to create a mock table view and populate that with mock data to then get a mock cell, or is there a way to create an instance of a custom subclass of a UITableViewCell and test the layout of that immediately?
Aucun commentaire:
Enregistrer un commentaire