Issue
@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?
Solution
PowerMock lets you mock final classes and methods (and static methods, etc).
Answered By - joseca
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.