Need feedback on simple idea

Colin Putney cputney at whistler.com
Sat Apr 12 02:28:04 UTC 2003


On Friday, April 11, 2003, at 07:14  PM, German Morales wrote:

> Sometimes it happens to me that when writing Unit Tests I want to check
> internal state of an object, for example to see if it was affected by a
> message, and I end up writing (previously not needed) accessors for 
> some
> of the instance variables.
>
> Am I the only one?
> Unit tests should test as a black box only?
> If not, having public accesors is almost a need, at least the "get" 
> ones.

I'm a pretty strong believer in black-box unit testing. It does seem to 
require more work in setting up test fixtures, but I've found the tests 
much more useful when finished. I've also learned to be wary when I run 
across a case that's difficult to test without digging around inside 
the object. It often means I've done some clumsy design work that needs 
refactoring.

Cheers,

Colin



More information about the Squeak-dev mailing list