mercredi 7 janvier 2015

Returning String value from the Mockito when()

I am trying to specific String value in mockito using when() method like



@Mock Individual indProvider;
when(indProvider.asProvider().getProviderId()).thenReturn("795316051750");


But I am getting exception



org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
0 matchers expected, 1 recorded.
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));

For more info see javadoc for Matchers class.


How can I return specific String in such case?


Aucun commentaire:

Enregistrer un commentaire