jeudi 23 juillet 2015

Accessing private members for unit testing

Usually when I'm writing an unit test in C++, I declare the test class friend to the tesee. That way I can inspect the results of the operation directly by inspecting the member variables. Java does not have friends, so how do you achieve the same behavior? I'm not talking about simple getters and setters here where testing is trivial, but situations where the results of the operation are stored internally in the class and it's not exposed to the outside world.

Aucun commentaire:

Enregistrer un commentaire