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

From: Date: Sat, 28 Mar 2009 13:46:58 +0000
Subject: Re: Should private/protected methods be included in test?
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-51685@lists.php.net to get a copy of this message
Dmitri Snytkine a écrit :
And how can you test private method if they cannot be called from outside the class?
Well, among other reasons (subclassing) that's why it's better to use a protected method instead of a private method, unless you have a very good reason to make it private. I you still have private methods, well, there's no way to test them directly, but you can always test the protected or public method that calls it, and check that the private method code coverage is ok. -- David

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