3 ms·
Because it’s assumed those private methods’ usage happens within public methods, which should be tested. By testing the public methods and all of its use cases
by bmy78 5y ago
Because it’s assumed those private methods’ usage happens within public methods, which should be tested. By testing the public methods and all of its use cases you are also testing private ones. That way you can arbitrarily modify private methods without touching the tests (presuming you’re refactoring and don’t need to modify behavior).
- exdsq 5y agoThis seems to be building on rocky foundations though. It's unlikely a functions entire test vector gets checked during testing. This is a known risk (you can't test everything) but by leaving all the functions under a public function untested there is no safety net.
- moron4hire 5y agoIf the code of the private methods cannot be fully exercised through the class' public interface, then that code never executes and should not even be in the function.