From: Brian Candler Date: 2007-03-30T04:09:16+09:00 Subject: Re: passing data to tests with test/unit On Fri, Mar 30, 2007 at 12:41:54AM +0900, Matt Berney wrote: > This would work ok if there was only one test method and only 3 types. > Now let's say that I want to use this test technique multiple times, > with multiple test methods. And, the data input is over 100 items. > Duplicating this structure 100 times doesn't seem tenable. ... > > class TC_CreateOrder1 < TC_CreateOrder > > FIXTURE = TYPE1 > > end > > > > class TC_CreateOrder2 < TC_CreateOrder > > FIXTURE = TYPE2 > > end > > > > class TC_CreateOrder3 < TC_CreateOrder > > FIXTURE = TYPE3 > > end But this was just an example; if this works then you can do it dynamically. How about something like: $test_classes = [] fixtures = [TYPE1, TYPE2, TYPE3] fixtures.each do |f| klass = Class.new(TC_CreateOrder) klass.const_set(:FIXTURE, f) $test_classes << klass # to prevent garbage collection end