Which is the best practise to follow for writing unit test cases for private/protected
methods of java
classes, when my test code and source code are in two different source packages (in eclipse
) and why would you suggest that? (I don't want to expose the methods as public to clients).
I have come to know few methodologies followed by developers like
- Using
Reflection
- Creating a subclass of the class under test that overrides the methods you want to test as public, and having those overridden methods call the original methods with the super keyword.
- Using
PowerMockito
overMockito
Please feel free to add any other methodology if you have followed, that are not not above.
Aucun commentaire:
Enregistrer un commentaire