Is there any way that we can mock certain methods using existing objects ?
I used Power Mock to mock private methods but couldn’t find out a way to do the above mentioned task.
Thanks
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.
If I understand correctly, you need to stub out just a method of a real object. If that is the case and if you’re using PowerMock with Mockito you can check out the ‘Spy’ feature. You can find an example here.