voglio fare questo:Mockito Matchers.any (...) su un argomento solo
verify(function, Mockito.times(1)).doSomething(argument1, Matchers.any(Argument2.class));
Dove argument1 è un'istanza specfic di tipo argument1 e argument2 è un qualsiasi istanza del tipo Argument2.
Ma ottengo un errore:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers! 2 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"));
In seguito a tale consiglio che posso scrivere il seguente ed è tutto a posto:
verify(function, Mockito.times(1)).doSomething(Matchers.any(Argument1.class), Matchers.any(Argument2.class));
Dove sto cercando qualsiasi arguement di tipo argument1 e qualsiasi argomento di tipo Argument2.
Come posso ottenere questo comportamento desiderato?
Fissarmi in faccia mi serve per non aver letto il mio tempo! Grazie per quello. –