Test::Unit run order

Hey there! I had a question about the order tests are run in
Test::Unit. I have a class with about 10 tests and I'd like to be able
to better control the order they run in. Right now they just run
alphabetically, and I could just add prefixes to my test names, but
I'm likely not going to be the one updating this code in the future
and I'd like to keep it as straightforward and simple as possible
(i.e. not end up with test_admintests_part1_login as a test name). I'm
keeping them all in one class because I'm using CI_reporter to
generate the XML results and I'd like it to be in one file. Is there
any way to change the order individual tests run, or is there a way to
have CI_reporter create only 1 XML file for multiple test suites. I've
looked around quite a bit for answers to either of these questions but
have so far found nothing (although it's a distinct possibility that I
just totally missed it an need a smack on the head). :slight_smile: Thank you very
much!

I can't speak about your XML stuff, but I'm pretty sure the
Test::Unit::TestCase.suite method sorts the tests by name so you can't
change the order. Your options are:

1) Construct the test suite yourself rather than relying on the above method
to do it for you. You'll have to dig around in Test::Unit's source to figure
out how to run tests without using AutoRunner.

2) Take a look at some of the code in test/unit/ui and look at the logging
events that tests fire. These should allow you to collect event data and
reorder it however you like before creating a report.

Both will require some inspecting of Test::Unit's source, but I'm sure
others have better suggestions. Test::Unit's README is pretty good if you
need to know some details on its internals, e.g. how TestCases are converted
to suites and run.

I believe you can number tests.
e.g. test_01_blah_etc, test_02_blah
I can't verify at the moment if this actually works or is just alpha order. I.e. That test_11_blah will be where you expect it

ยทยทยท

On Jul 15, 2009, at 1:33 PM, James Coglan <jcoglan@googlemail.com> wrote:

2009/7/15 Dylan <mejari@gmail.com>