Search code examples
jmock

Jmock match string parameter exactly


I read from Jmock's homepage about matchers, and at the very top there was an example about string matchers. I didn't understand because, according to the example, matching a string would be as easy as writing import static org.hamcrest.Matchers.*; and then using the stringContains function, but that doesn't work on my implementation.

All I want to do is

new Expectations() {{
  mockedType.someFunction(with(   **match string here**    ) );
}};

Solution

  • new Expectations() {{
        allowing(mockedType).someFunction("My String"); when  ... ; will ... ; then ...
    }};
    

    Must be working