On Sat, 26 Aug 2000, Dave Thomas wrote: > > > I have a Test_MyClass < RUNIT::TestCase class that tests my class MyClass. > > > I want to run the tests for different parameters to MyClass. How do this > > > nicely? > > How about subclassing Test_MyClass using something like: > > class Test_MyClass > # > # hundreds of wonderful tests... > # using the instance variable @myClass > end > > class Test_MyClass_Alg1 < Test_MyClass > def setup > @myClass = MyClass.new(MyClass::ALG1) > end > end > > class Test_MyClass_Alg2 < Test_MyClass > def setup > @myClass = MyClass.new(MyClass::ALG2) > end > end > > class Test_MyClass_Alg3 < Test_MyClass > def setup > @myClass = MyClass.new(MyClass::ALG3) > end > end > > > That way the tests remain the same, and all you change is the setup. > Yes, that's a solution. IMHO, it's not very "beautiful" since you need to duplicate code and I thought there might be a simpler way... (Now I suspect you'll tell me thta I should be pragmatic and write a code generator? :-)) Thanks anyway, Robert