--_540597738
Content-Type: text/plain; charset="us-ascii"; format=flowed

I'm using ruby 1.8.2 (2004-12-25) [i686-linux] and I've noticed that the 
order unit tests are defined in the testing file does not correspond to the 
order they are performed in. Instead, the order is simply alphabetical. If 
you want to order your tests, you have to name your test methods 
accordingly and I find this somewhat awkward.

Is this a bug or is it simply not part of the unit testing methodology to 
have a sequence of tests, assuming some order-independent set of tests instead?

Anyhow, if this is indeed something worth fixing, I've attached a patch 
with some changes I made to /pathtoruby/ruby/1.8/test/unit/testcase.rb. 
It's a bit of a hack, but it works. In your test class, you will also need 
to include a few extra lines to make the ordering work. Here's an example 
test file:

require 'rubyunit'

class SomeTest < Test::Unit::TestCase

   attr_reader :method_order, :enable_method_ordering

   @enable_method_ordering  rue
   @method_order  ]

   @method_order << "test_c"
   def test_c
       assert(1 0)
   end

   @method_order << "test_a"
   def test_a
       assert(1 0)
   end

   @method_order << "test_b"
   def test_b
       assert(1 0)
   end

end


This will run tests in the order c,a,b. If you use @enable_method_ordering 
 alse, it will use alphabetical ordering instead.

Attached is the patch for /pathtoruby/ruby/1.8/test/unit/testcase.rb

Thanks,

-Jordan 



--_540597738
Content-Type: application/octet-stream; name="testcase.rb.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="testcase.rb.patch"

LS0tIHRlc3RjYXNlLnJiLjAJMjAwNC0wNS0xNiAxMjoxNjozOC4wMDAwMDAwMDAgKzA4MDAKKysr
IHRlc3RjYXNlLnJiCTIwMDUtMDYtMjMgMjA6MDc6MDIuMDAwMDAwMDAwICswODAwCkBAIC00Myw4
ICs0MywyMyBAQCBtb2R1bGUgVGVzdAogICAgICAgIyBlYWNoIG1ldGhvZC4KICAgICAgIGRlZiBz
ZWxmLnN1aXRlCi0gICAgICAgIG1ldGhvZF9uYW1lcyA9IHB1YmxpY19pbnN0YW5jZV9tZXRob2Rz
KHRydWUpCi0gICAgICAgIHRlc3RzID0gbWV0aG9kX25hbWVzLmRlbGV0ZV9pZiB7fG1ldGhvZF9u
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