I understand that ideally a method should be private if it is not supposed to be used outside of the class. But this approach is makes it difficult to unittest the method and you will have to use reflection. There is an opinion that the private methods should not be tested separately and should be considered an implementation detail of the public methods that use them. Personally I prefer a file grain approach to my testing and I like to know the exact spot when something is working not as it was supposed to and that is why I like to have a separate test for each method. But I admit that I may be missing something and I would like to hear arguments for using private methods and writing unit tests only for public methods. In this case I miss the purpose of package-private and when to use this modifier.
Aucun commentaire:
Enregistrer un commentaire