By alashcraft
via lostechies.com
Published: Nov 23 2008 / 18:33
You should only be testing public methods. Private methods are an implementation detail of the object and are subject to heavy change, etc. Any class, including test fixtures, that care about private methods on another object exhibit the “Inappropriate intimacy” code stench.
Tweet
SaveShareSend
Tags: frameworks, methodology, opinion, trends
Comments
zynasis replied ago:
fits perfectly with bdd imo
Motion Control replied ago:
How would you call a private method from outside the class anyway? (Don't tell me about reflection etc.)
zone_reader replied ago:
Make it public but do not test it after that either :)
chadmyers replied ago:
Yes, generally people use reflection to test the method. Sometimes they'll make it protected and create a test class that derives from the class-under-test in order to be able to call it. All in all, it's very smelly/hacky which should be everyone's first indication that this is not a good practice.
stugots replied ago:
zynasis replied ago:
so's ur face
chadmyers replied ago:
For the Vote-downs, I'm curious why you voted this down. Can you please comment? Thanks!
BlackWasp replied ago:
I have often wondered that. Shame Dzone doesn't force you to explainwhy you think something is bad.
stugots replied ago:
Maybe it's moronic?
chadmyers replied ago:
Maybe what is moronic? Please elaborate.
zynasis replied ago:
so's ur face
ZING!
Voters For This Link (15)
Voters Against This Link (5)