Testing if a UI element is hidden in an OCUnit test
- by Logan Serman
I have a button that is hidden under certain circumstances that I wish to test. The button is hidden with [theButton setHidden: YES] in the viewDidLoad method if it is appropriate. For simplicity, lets say that the button is hidden when the buttonIsHidden property is set to true in the view controller.
Right now I am trying the following:
self.viewController = [[ViewController alloc] init];
self.viewController.buttonIsHidden = YES;
[self.viewController loadView];
UIButton *theButton = [...] // function I wrote to retrieve the button based on it's touch up inside action
if (theButton) {
NSLog(@"%c", theButton.hidden);
return (theButton.hidden == true)
}
return NO;
It looks like the hidden property is not what it should be, the NSLog lines from the above code are blank. But, if I output another property like the height, it outputs the correct value so I know it is getting the right button.
How do I access the hidden property of the button in this case?