Suppose you want mock to use an interface Mockitocontaining the following method signatures:
public void doThis(Object o);
public void doThis(Object... o)
I need to verify that doThis(Object o)(and not another method) was called exactly once.
At first, I thought the following line would do the trick:
verify(mock, times(1)).doThis(anyObject());
However, since this seems to work on Windows, it does not work on Linux because another method is expected to be called in this environment doThis.
This is because the argument appears to correspond to both method signatures , and one is chosen in a more or less unpredictable way. anyObject()
How can I guarantee that Mockito always choosesdoThis(Object o) to check?
source
share