ios - How to write unit test for testing view controller? -
we trying write our custom unit tests testing every view controller separately. know there ui automation, kif, , other solutions, if take @ code above find should possible without using them. so, simplicity, suppose there's simple view controller 2 public methods "setfirststate" , "setsecondstate". need test, "setfirststate" method called when view controller instantiated , shown on screen (goes through viewdidload). here's demo view controller: @interface myviewcontroller - (void)setfirststate; - (void)setsecondstate; @end @implementation myviewcontroller - (void)viewdidload { [super viewdidload]; [self setfirststate]; } @end so, unit test testing setfirststate call (using xctest , ocmock): - (void)test_viewdidload_callsmymethod { myviewcontroller *viewcontoller = [[myviewcontroller alloc] init]; id mock = [ocmockobject partialmockforobject:viewcontoller]; [[mock expect] showlogin]; [uiapplication sha...