samedi 16 avril 2016

Best practise to follow for unit testing private/protected methods in Java [on hold]

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

  1. Using Reflection
  2. 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.
  3. Using PowerMockito over Mockito

Please feel free to add any other methodology if you have followed, that are not not above.





Aucun commentaire:

Enregistrer un commentaire