From: Matt Berney Date: 2007-03-31T00:43:57+09:00 Subject: Re: passing data to tests with test/unit Thanks to everyone who posted responses. Through a combination of your feedback and experimentation, here is the solution I came up with: class TC_CreateOrder < Test::Unit::TestCase def test_NewOrder orderTypeList = File.open('orders.yaml') { |yf| YAML::load(yf) } orderTypeList.each { |type| # perform the test assert "order successful" @_result.add_run end end The trick was the last line "@_result.add_run". By adding this line, each time through the loop increments the test count such that each order is a separate test case. Nasir Khan wrote: > 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 -- Posted via http://www.ruby-forum.com/.