“Nathaniel Talbott” nathaniel@talbott.ws writes:
The problem is that there is no good way to run the tests in the
order defined.class TestCase
class << self
def method_added(symbol)
# how would matz do this Perlish test?
if symbol.id2name =~ /^test_/
Matz called “perlish” this
if /^test_/
There’s nothing “perlish” in your test. As far as I understand, Matz is
only against operations on implied operands. Sorry for an off-topic
remark.
···
On Monday, Jan 27, 2003, at 20:10 US/Pacific, Matt Armstrong wrote:
@test_methods ||=
@test_methods << symbol
end
end
attr_reader :test_methods
end
endclass MyTestCase < TestCase
def test_zzz; end
def test_mmm; end
def test_aaa; end
endclass MyTestCase2 < TestCase
def test_zzz2; end
def test_mmm2; end
def test_aaa2; end
endp MyTestCase.test_methods
#=> [:test_zzz, :test_mmm, :test_aaa]
p MyTestCase2.test_methods
#=> [:test_zzz2, :test_mmm2, :test_aaa2]Anyhow, on running tests in (pseudo-)random order, that’s one of the
test orderings I’d like to implement in the future. The only problem
with it is, if things fail when you’re running them randomly, you’ll
want to know what order they were run in that particular time so you
can fix the problem. Otherwise it might be more frustrating than
helpful.I can think of 2 solutions here:
- Test::Unit supports saving the order of the tests it runs in a text file, and can parse that file and run the tests in the same order. - Test::Unit includes its own random number generator, spits out the random seed it is using, and can support seeding its RNG to a particular number. (you can't use Ruby's RNG since tests themselves might use it)