Android Mockito TooManyActualInvocations

Answer #1 100 %

TooManyActualInvocations means... too many actual invocations.

This has to work fine:

@Test
fun doSomethingTest() {
    myPresenter.doSomething()
    Mockito.verify(mockView, times(2)).enableProgressBar(0)
    Mockito.verify(mockView).enableProgressBar(1)
    Mockito.verify(mockView).enableProgressBar(2)
}

As enableProgressBar was called twice with 0 argument, then the assertion should be appropriate (should assert that it was called twice). Or you can use some convenient Mockito methods such as atLeastOnce(), atMost(2), etc. instead of straightforward times if you want to leave some space for implementation specifics.

You’ll also like:


© 2023 CodeForDev.com -