[squeak-dev] Re: Subclassing tests Style Question

Zulq Alam me at zulq.net
Mon Jul 21 16:13:48 UTC 2008


Hi Herbert,

Sounds to me like you should delegate set up to a helper class that is 
used by both test case classes. Perhaps even a TestResource 
(http://www.metaprog.ch/downloads/TestResources.pdf).

Regards,
Zulq.

Herbert König wrote:
> Hi,
> 
> I have two classes say A and B.
> 
> B has a collection of A which is quite complex.
> 
> Laziness suggests to make BTests a subclass of ATests so I could reuse
> the (lengthy) setUp of A in A tests. Something like
> 
> BTests>>setUp
>  super setUp
>  ..stick a copy ATests A into BTests B
>  super setUp
>  ...add a slightly modified copy of ATests A into BTests B
> 
> The gut feeling says BTests should not inherit from ATests if
> B does not inherit from A.
> 
> But copying all that A setup code from ATests to BTests does not seem
> right either.
> 
> Hey that's the first time I think using a Trait might not be that
> bad??
> 
> Making a class with the only purpose to return initialised instances
> of A??
> 
> Any advice is much appreciated!
> 
> 
> Thanks,
> 
> Herbert 
> 
> 
> 




More information about the Squeak-dev mailing list