0

I am working on JUNIT, where i need to verify a method whether it is called or not. so i added below code

verify(mock).method();

When i run i am getting below exception

org.mockito.exceptions.verification.TooManyActualInvocations: 
mock.method();
Wanted 1 time:
But was 36 times:

I understand it was invoked 36 times but wanted only one time. help me in fixing this issue

rocky
  • 753
  • 2
  • 10
  • 26
  • Possible duplicate of [How to verify a method is called two times with mockito verify()](https://stackoverflow.com/questions/14889951/how-to-verify-a-method-is-called-two-times-with-mockito-verify) – mystarrocks Jan 17 '19 at 15:20

1 Answers1

5

With Mockito you can do that by specifying that your method should be called atleast once.

For example:

verify(mock, atLeastOnce()).method();

For more information: Link

Mohammed Rampurawala
  • 3,033
  • 2
  • 22
  • 32