[Tutor] Unit testing

Alan Gauld alan.gauld at freenet.co.uk
Tue Jun 27 06:10:26 CEST 2006


> Ok, that leads me to my next question.  Currently, I have a class 
> that I
> want to unit test, but it contains a semaphore from another class. 
> Now, I
> could make the semaphore a global variable, or I bring in the other 
> class.
> One violates "good" programming principles and the other violates 
> the unit
> testing principles. Is there another way?

Reconsider your definition of a "Unit" maybe?
A Unit should stand alone, it is the smallest amount of code that can
stand alone.

If your class relies on another class maybe both classes need to be
considered as a single unit? Or maybe the classes need to be 
refactored to
make them less closely coupled?

Alan G. 




More information about the Tutor mailing list