@Test
public void testWhenUserNameAndPasswordAreEnteredShouldAttemptLogin() throws Exception {
LoginView loginView = Mockito.mock(LoginView.class);
Mockito.when(loginView.getUserName()).thenReturn("George");
Mockito.when(loginView.getPassword()).thenReturn("aaaaaa");
loginPresenter.setLoginView(loginView);
loginPresenter.onLoginClicked();
Mockito.verify(loginPresenter).attemptLogin(loginView.getUserName(), loginView.getPassword());
}
This is my test, but as loginPresenter
is a class
generated from AndroidAnnotations
and it is final
, I cannot spy
on it.
So is there another way (not necessarily using mockito) to verify that this method has been invoked?