Package org.mockito.stubbing
Interface Answer1<T,A0>
-
- Type Parameters:
T
- return typeA0
- type of the single argument
public interface Answer1<T,A0>
Generic interface to be used for configuring mock's answer for a single argument invocation. Answer specifies an action that is executed and a return value that is returned when you interact with the mock.Example of stubbing a mock with this custom answer:
import static org.mockito.AdditionalAnswers.answer; when(mock.someMethod(anyString())).then(answer( new Answer1<Integer, String>() { public Integer answer(String arg) { return arg.length(); } })); //Following will print "3" System.out.println(mock.someMethod("foo"));
- See Also:
Answer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
answer(A0 argument0)
-