I need to write a unit test that checks that pressing the button will cause the proper IBAction
to be called.
Here is my test method:
- (void)testWhether_loginBtnTapped_IsCalledAfterUserTapLoginButton
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
GoingToLoginViewController *myViewController = [storyboard instantiateViewControllerWithIdentifier:@"GoingToLoginVC"];
id vcMock = [OCMockObject partialMockForObject:myViewController];
[[vcMock expect] loginBtnTapped:[OCMArg any]];
[myViewController.loginBtn sendActionsForControlEvents:UIControlEventTouchUpInside];
[vcMock verify];
}
When I run the test I have log message:
error: testWhether_loginBtnTapped_IsCalledAfterUserTapLoginButton (Ticket2Tests) failed: OCPartialMockObject[GoingToLoginViewController]: expected method was not invoked: loginBtnTapped:<OCMAnyConstraint: 0xfd3aeb0>
And when I run my app on the simulator the button works appropriately and - (IBAction)loginBtnTapped:(id)sender;
was called.
What did I do wrong and what should I do to make the test pass?