Когда я делаю:
verify(authenticatorMock, timeout(1000).times(9)).authenticateUser(username, password);
, это дает мне следующую ошибку:
Требуется 9 раз: -> at com.mokitoTutorial.app.AuthenticatorApplicationTest.testAuthenticate (AuthenticatorApplicationTest.java:39) Но было 1 раз: -> at com.mokitoTutorial.app.AuthenticatorApplication.authenticate (AuthenticatorApplication.java:28)
Почему проверяется только 1 раз?
@Test
public void testAuthenticate() {
AuthenticatorInterface authenticatorMock;
AuthenticatorApplication authenticator;
String username = "JavaCodeGeeks";
String password = "unsafePassword";
authenticatorMock = Mockito.mock(AuthenticatorInterface.class);
authenticator = new AuthenticatorApplication(authenticatorMock);
when(authenticatorMock.authenticateUser(username, password))
.thenReturn(false);
boolean actual = authenticator.authenticate(username, password);
verify(authenticatorMock, timeout(100).times(9)).authenticateUser(username, password);
System.out.println("wait");
assertFalse(actual);
}