From: Matt Armstrong Date: 2003-01-28T15:53:44+09:00 Subject: Re: Test::Unit -> order of tests? writes: > Matt Armstrong [mailto:matt@lickey.com] wrote: > >> > 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) [...] >> end >> attr_reader :test_methods >> end >> end [...] > That's pretty slick! I had a feeling as soon as I said it wouldn't > work that someone would propose a solution. There might be an issue > with doing this, though - after a little IRB'ing here, it appears > that including a module will not trigger #method_added for each > method of the module. But perhaps there's a way around that, too :-) Ooh, yeah, yuck. The included module won't have a list of methods in declaration order anyway. You'd have to a method_added hook on Object or Module and track all classes just in case they are included in a TestCase -- not pretty. > Also, and it could just be me being over-cautious, but adding test > methods by trapping their definition seems to be more vulnerable to > problems than waiting until it's time to run them and _then_ > gathering them from where I expect them to be. I don't have to worry > about missing anything, as Ruby is collecting it all for me. But I'm > a worrywart. Yes, it requires Test::Unit to become more involved with Ruby's internal guts (method_added, etc.) than makes me comfortable too. Alphabetical order is simple to define, easily verifiable, and fits in most people's heads.