From: Matt Berney Date: 2007-03-30T00:41:54+09:00 Subject: Re: passing data to tests with test/unit Thanks Brian, 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. What I am really looking for is a data-driven test method, such that I can use the same test case and pass it different data. However, for test execution and measurement purposes, it is preferable to record these as separate tests. Brian Candler wrote: > On Thu, Mar 29, 2007 at 06:23:14AM +0900, Matt Berney wrote: >> end >> return suite >> end >> end >> >> Test::Unit::UI::Console::TestRunner.run(TS_OrderTests) > > If it's only one test method, you can factor it out in the class: > > class TC_CreateOrder < Test::Unit::TestCase > def do_test(t) > .. process t > end > > def test_type1 > do_test(TYPE1) > end > > def test_type2 > do_test(TYPE2) > end > > def test_type3 > do_test(TYPE3) > end > end > > Otherwise, how about: > > class TC_CreateOrder1 < TC_CreateOrder > FIXTURE = TYPE1 > end > > class TC_CreateOrder2 < TC_CreateOrder > FIXTURE = TYPE2 > end > > class TC_CreateOrder3 < TC_CreateOrder > FIXTURE = TYPE3 > end > > (I'm not sure how you'd prevent the base test TC_CreateOrder being run) > > Regards, > > Brian. -- Posted via http://www.ruby-forum.com/.