I have a line in my test that currently looks like:
Mockito.verify(mockMyObject).myMethod(Mockito.contains("apple"));
I would like to modify it to check if the parameter contains both "apple"
and "banana"
. How would I go about this?
I have a line in my test that currently looks like:
Mockito.verify(mockMyObject).myMethod(Mockito.contains("apple"));
I would like to modify it to check if the parameter contains both "apple"
and "banana"
. How would I go about this?
Check this article Argument matching with Mockito for working example.
Just use Mockito.match(String)
Mockito.verify(mockMyObject).
myMethod(
Mockito.matches("(.*apple.*banana.*)|(.*banana.*apple.*)"
)
);