It is kinda easy to unit test IBOutlets, but how about IBActions? I was trying to find a way how to do it, but without any luck. Is there any way to unit test connection bet
So, it is probably possible to instantiate a view controller from a storyboard or nib and then do a touch down on a UIButton. However, I wouldn't do this because you are then testing an Apple stock API. Rather, I would test by directly calling the method. For example if you have a method - (IBAction)foo:(id)sender
in your view controller and you need to test the logic in that method, I would do something like this:
MyViewController *viewController = [[MyViewController alloc] initWithNibName:@"NibName" bundle:[NSBundle mainBundle]];
UIButton *sampleButton = [[UIButton alloc] init];
[sampleButton setTitle:@"Default Storyboard Title" forState:UIControlStateNormal];
[viewController foo:sampleButton];
// Run asserts now on the logic in foo: