DEV Community

Discussion on: What "accepted truth" in software development do you find questionable?

Collapse
ddarrko profile image
Daniel Benzie

I disagree here. Your private methods are implementation details. You should only need to test the public interface to the API. If you are finding your public methods are dependent on too many various private methods it is a sign that they themselves can be broken into a class.

Thread Thread
dystroy profile image
Denys Séguret

Your private methods are implementation details

Yes but tests are also meant to check the implementation works as intended.

If you are finding your public methods are dependent on too many various private methods it is a sign that they themselves can be broken into a class.

It's more often the opposite: a core private function, accessed through several public functions, none of them covering the whole possibilities of the function doing the real job (and the one also which may fail). In such a case, testing all the public functions adds a lot of noise and reduces the stress put on the function which matters.