From: brabuhr@... Date: 2008-01-25T07:55:09+09:00 Subject: Re: Scripts run using load in "for" loop run out of order On Jan 23, 2008 1:31 PM, Fa Sidd wrote: > Hi > I am new to ruby and like it so far. > ... First, since you are new to Ruby, some alternate ways to code your sample: > testList = [] > > testList[0]="Tests/D-test.rb" > testList[1]="Tests/C-test.rb" > testList[2]="Tests/A-test.rb" > testList[3]="Tests/B-test.rb" a) Append to the array instead of directly indexing: testList = [] testList << "Tests/D-test.rb" testList << "Tests/C-test.rb" testList << "Tests/A-test.rb" testList << "Tests/B-test.rb" b) Directly initialize the literal array: testList = [ "Tests/D-test.rb", "Tests/C-test.rb", "Tests/A-test.rb", "Tests/B-test.rb" ] c) Initialize an array of words: testList = %w{ Tests/D-test.rb Tests/C-test.rb Tests/A-test.rb Tests/B-test.rb } > begin > for i in 0 .. testList.length-1 > puts "i: #{i} testname: #{testList[i]}" > load(testList[i]) > end > end a) Instead of explicit loop and indexing, iterate testList.each do |test| puts "testname: #{test}" load test end b) If you still want the index too testList.each_with_index do |test, i| puts "#{i} \t #{test}" load test end And, as to your question, perhaps you could try explicitly invoke the TestRunner: # load all of the test cases Dir.glob("./Tests/*.rb").each do |tfile| require tfile end # run the test cases explicitly in order [ TC_Four, TC_Three, TC_One, TC_Two ].each do |tclass| Test::Unit::UI::Console::TestRunner.run(tclass) end See "Test Runners" and "Test Suite": http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html