I have unsuccessfully tried to get an instance of a custom UITableViewCell in order to unit test it with the SenTestingKit framework. This is the code I used in my testing class:
CustomTableViewCell *cell = nil;
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCell" owner:self options:nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass:[CustomTableViewCell class]])
cell = (CustomTableViewCell*)oneObject;
I know it loads the NIB properly because the array nib contains an instance of the class CustomTableViewCell at its first position but i haven’t managed to get it out of the array at all.
Has anyone achieved the testing of UITableViewCell ? Does anyone know a workaround for this?
Any help or directions would be immensely appreciated
EDIT:
I have solved the issue using the initWithStyle:reuseIdentifier: method to initialize the UITableViewCell class instance.
If you are running these tests out of container (simulator), anything that relies on
loadViewbeing called is likely not going to be testable. I recommend unit testing that which can be tested out of container only.