views:

41

answers:

2

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?

+1  A: 

Check this article Argument matching with Mockito for working example.

DixonD
+1 This article helped with another problem I came to - thanks :-)
tttppp
+3  A: 

Just use Mockito.match(String)

Mockito.verify(mockMyObject).
  myMethod(
    Mockito.matches("(.*apple.*banana.*)|(.*banana.*apple.*)"
  )
);
Boris Pavlović