From: zetetic Date: 2008-01-24T16:40:00+09:00 Subject: Re: Scripts run using load in "for" loop run out of order On Jan 23, 1:32 pm, Fa Sidd wrote: > Thomas Preymesser wrote: > > in your code, your are not 'running' the test cases with your order > > you're just loading Testcase declarations. All the collected test > > classes > > are 'run' when your loop is finished. > > The test-classes are running in alphabetical order ("TC_Four", "TC_One", > > "TC_Three", "TC_Two") > > Thanks for your response. > > Is there a way I can run the scripts in the correct order in the loop? > -- > Posted viahttp://www.ruby-forum.com/. To execute a test, you need to run it as follows: Test::Unit::UI::Console::TestRunner.run(test) Try replacing everything after Dir.chdir TOPDIR with the following: Dir["Tests/*.rb"].each {|testfile| load "#{testfile}"} [TC_Four,TC_Three,TC_One,TC_Two,].each {|test| Test::Unit::UI::Console::TestRunner.run(test) } or if you want to name the files explicitly, you could do: testList = %w(Tests/A-test.rb Tests/B-test.rb Tests/C-test.rb Tests/ D-test.rb) testList.each {|testfile| load "#{testfile}"} [TC_Four,TC_Three,TC_One,TC_Two,].each {|test| Test::Unit::UI::Console::TestRunner.run(test) } This loads all the test classes first, then executes them in the order you specify. Change the order of the classes in the second line if you want to change the order of the tests.