4 ms·
Private methods shouldn't be tested, and if you feel like they need to be tested then chances are your private methods should be public. I've seen private meth
by ravenstine 5y ago
Private methods shouldn't be tested, and if you feel like they need to be tested then chances are your private methods should be public.
I've seen private methods used within internal projects at companies, and admittedly I've created many private methods in this condition, but unless what you're shipping is a library then what exactly is the point of making your methods private? To stop the developers from misusing their own code?
For the most part, I sometimes use private methods in my own projects as just a way to make it more immediately apparent that something is just supporting code for something else. If no one else is using the code as an API, and it somehow turns out that the private code needs to be tested directly, it becomes a candidate to be promoted to public because there'd be no reason for it to be private at that point.