From: Phlip Date: 2009-03-24T06:36:57+09:00 Subject: Re: Test::Unit - same test, different "args" Luke St.Clair wrote: > I need to run the same unit test case more than 10 times (around 150 > tests in the test case), with 2-3 parameters changed each time. > > For instance, if I had unit tests to examine a "Person", with a > required parameter "name" - let's say I want to run the same > Test::Unit::TestCase on 10 different people, with different names but > everything else the same. All test cases run the same code, just with > the one (or two) parameters tweaked. Put all the test_ methods into a module, and include it into 10 different suites: class ATest < Test::Unit::TestCase; include Suite; setup; @me = 'a'; end; end class BTest < Test::Unit::TestCase; include Suite; setup; @me = 'b'; end; end class CTest < Test::Unit::TestCase; include Suite; setup; @me = 'c'; end; end class DTest < Test::Unit::TestCase; include Suite; setup; @me = 'd'; end; end there might be a less effusive way, but the Abstract Test Pattern is very important to learn, so this is a good start... > What's the right approach here? Abstract Test is best to match an important class hierarchy in your code. Otherwise, the question arises are you missing an abstraction? Could you simplify something else, and test fewer permutations?