Re: Should private/protected methods be included in test?

From: Date: Sat, 28 Mar 2009 10:33:35 +0000
Subject: Re: Should private/protected methods be included in test?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-51682@lists.php.net to get a copy of this message
Hello,
Hello! Just wondering, what do you usually include in your test suite? Some websites recommend testing all public methods. This makes sense with exception of simple getters/setters methods. But what about the private/protected methods? Whould I also write test cases for those?
Yes they should be tested, even more thoroughtly because private/protected methods often handle the most critical parts of your logic !
By the way, is it OK to not write tests for simple getters/setters that only return or set an instance variable?
Yes, they should also be tested, if one day you change those getters/setters to do more than setting a protected property, you'll be happy to have them covered by tests. Anyway, you won't get a good code coverage if you skip code. -- David

« previous php.pear.dev (#51682) next »