title: How to write a unit test that checks that pressing the button will cause to calling the proper IBAction?
body: <p>I need to write a unit test that checks that pressing the button will cause the proper <code>IBAction</code> to be called.</p>
  
  <p>Here is my test method:</p>
  
  <pre><code>- (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];
  }
  </code></pre>
  
  <p>When I run the test I have log message: </p>
  
  <pre><code>error: testWhether_loginBtnTapped_IsCalledAfterUserTapLoginButton (Ticket2Tests) failed: OCPartialMockObject[GoingToLoginViewController]: expected method was not invoked: loginBtnTapped:&lt;OCMAnyConstraint: 0xfd3aeb0&gt;
  </code></pre>
  
  <p>And when I run my app on the simulator the button works appropriately and <code>- (IBAction)loginBtnTapped:(id)sender;</code> was called.</p>
  
  <p>What did I do wrong and what should I do to make the test pass?</p>