mercredi 25 février 2015

Mocking Java objects in my target where target has no setters available

The situation is that I have to write Unit test for one of Java class. That java class in the constructor creates object of another class(3rd party), no so setter available for setting the 3rd party class.


I do not have the 3rd party class available with me, so would like to mock it. So is it possible by Mockito or any other framework or any other suggestion.


One option I see is to self create that 3rd party class (with same package info) and provide called functions returning whatever I wish and provide class path where these mocked will exist.


Aucun commentaire:

Enregistrer un commentaire