Consider a method signature like:
public String myFunction(String abc);
Can Mockito help return the same string that the method received?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since Mockito 1.9.5+ and Java 8+
You can use a lambda expression, like:
For older versions
You can create an Answer in Mockito. Let’s assume, we have an interface named MyInterface with a method myFunction.
Here is the test method with a Mockito answer: