------art_33257_20312580.1175196596768
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

You could write a private method in your test class which is called from a
public test method which in turn gets the data from a YAML file or some
other data source.

e.g

------------------------------------------------------
require 'test/unit'

class MyTest < Test::Unit::TestCase

  def test_public
    3.times { |i| _test_private(i) }  # get your input data here before
calling private method
  end

  def _test_private(arg)
    puts  "Now testing with #{arg}"
    assert(true)
  end

private :_test_private
end

-------------------------------
Loaded suite test
Started
Now testing with 0
Now testing with 1
Now testing with 2

- nasir


On 3/29/07, Matt Berney <matt_watir / hotmail.com> wrote:
>
> 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  YPE1
> > end
> >
> > class TC_CreateOrder2 < TC_CreateOrder
> >   FIXTURE  YPE2
> > end
> >
> > class TC_CreateOrder3 < TC_CreateOrder
> >   FIXTURE  YPE3
> > 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/.
>
>

------art_33257_20312580.1175196596768--