There are quite a few resources on unit testing whether just purely logical or application level, I am currently working trying to test a UITableViewCell
that has IBOutlets within a storyboard and as a few posts have confirmed if i wish to instantiate the storyboard and then the view controller that contains the cell. So you have to go through a few steps to make sure the storyboard and following elements load properly with their IBOutlets like so
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.vc = [storyboard instantiateViewControllerWithIdentifier:@"testTableViewController"];
[self.vc performSelectorOnMainThread:@selector(loadView) withObject:nil waitUntilDone:YES];
followed by this code to get a UITableViewCell
from the UITableViewController
[self.vc setTableViewData:@[@1].mutableCopy];
[self.vc.tableView reloadData];
[self.vc.tableView layoutIfNeeded];
SUT = [self.vc.tableView dequeueReusableCellWithIdentifier:@"More Menu Cell"
forIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
and this produces a cell however for me the first breakpoint i have inside the system under test, seems to indicate that the IBOutlets have loaded, however when i actually go to assert anything, they all of a sudden disappear one me...
either references are disappearing for no reason or I'm doing something wrong.
Aucun commentaire:
Enregistrer un commentaire