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 to resolve now is that my mock method should have the same number of parameters as protected method I want to mock. It forces me to create several mock methods with different number of parameters which is not elegant. Does anyone know better solution in JMock or other Java framework? Any help would be very appreciated.
Pinned topic How to mock protected method in Java
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2009-06-13T11:37:01Z at 2009-06-13T11:37:01Z by SystemAdmin
Re: How to mock protected method in Java2009-06-13T10:03:20ZThis is the accepted answer. This is the accepted answer.For more cross-posts
For more explanation
Re: How to mock protected method in Java2009-06-13T11:37:01ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
At least if somebody don't suggest anything better.