From: "bpettichord@..." Date: 2006-05-24T14:17:59+09:00 Subject: Re: Test::Unit Patch that allows test methods to be executed sequentially I was able to rewrite the code as a subclass. I was even able to prevent the problem with the incorrect test count that had been a reason i'd avoided this approach previously (see the initialize method). Comments please. I would be happy to present this code as a true patch to the Test::Unit source if there is actually interest in seeing it in that form. Is there? My sense was that most people felt this was best delivered as a subclass. (I may actually pull out the ordering options now, since they really don't serve a purpose -- yagni and all.) Bret require 'test/unit' module Watir class TestCase < Test::Unit::TestCase @@order = :sequentially def initialize name throw :invalid_test if name == :default_test && self.class == Watir::TestCase super end class << self attr_accessor :test_methods, :order def test_methods @test_methods ||= [] end def order @order || @@order end def default_order= order @@order = order end def sorted_test_methods case order when :alphabetically: test_methods.sort when :sequentially: test_methods when :reversed_sequentially: test_methods.reverse when :reversed_alphabetically: test_methods.sort.reverse else raise ArgumentError, "Execute option not supported: #{@order}" end end def suite suite = Test::Unit::TestSuite.new(name) sorted_test_methods.each do |test| catch :invalid_test do suite << new(test) end end if (suite.empty?) catch :invalid_test do suite << new(:default_test) end end return suite end def method_added id name = id.id2name test_methods << name if name =~ /^test./ end def execute order @order = order end end end end