Actually I'm not totally happy with the solution I have but for now it should be fine.
Thanks....
User Profile
Collapse
-
Thank you JosAH
That's what I'm doing right now. The problem is that if my protected method has 2 arguments then my mock method should be like
Object mockMethod(Obje ct parameter1, Object parameter2);
If I need to mock another protected method with 3 parameters then I have to create
Object mockMethod(Obje ct parameter1, Object parameter2, Object parameter3);
It works for...Leave a comment:
-
How to mock protected method in Java
Here is a question.
I wanted my JUnit tests to be more modular and found how to mock protected methods for that purpose. Briefly speaking, we cannot mock and control calls of protected method with JDK dynamic proxy because protected methods are not in any interface but we can create MockInterface with mock method under control and call it from overridden protected method to achieve our goal.
The problem I’m trying...
No activity results to display
Show More
Leave a comment: