
Unit Testing Private Methods
Quote:
>> > It seems that in order to be able to unit test a method it has to be
>> > publicly accessible. Is there a way to use test/unit to test private methods
>> > and instance variables?
>> I used to believe that Unit Testing would consider things in a black-box
>> approach. Can somebody comment on that?
> Thinking on it again, I should have written
> "white-box approach testing only public methods"
I try to only test public methods, but sometimes run into a situation
where testing private methods is good. This is generally when one
public method calls several large, implementation-heavy private
methods. In this case, the private methods are important, and it's
easier to test them directly to build some confidence.
In which case
does the job.
I like the fact that you can call private methods, but the code for
doing so sticks out.
Gavin