There is the question In Ruby, how to I control the order in which Test::Unit tests are run? and wanted to answer with a reference to test_order = :defined
,
The documentation for Test::Unit::TestCase.test_order
says:
Sets the current test order.
Here are the available order:
- :alphabetic Default. Tests are sorted in alphabetic order.
- :random Tests are sorted in random order.
- :defined Tests are sorted in defined order.
So I thought this would execute the tests in order of method definition:
gem 'test-unit'
require 'test/unit'
class Mytest < Test::Unit::TestCase
test_order = :defined
#~ test_order = :random
#~ test_order = :alphabetic #default
def test_b
p :b
end
def test_a
p :a
end
def test_c
p :c
end
end
But when I execute it (tested with test-unit 2.4.9 and 2.5), I get the alphabetic order:
Started
:a
.:b
.:c
.
What's the problem? Is there something missing in my code, is the documentation wrong or is there a bug?