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
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