Ordering tests in a testsuite

Ulrich Eckhardt eckhardt at satorlaser.com
Thu Oct 7 19:05:32 CEST 2010


Hello!

I'm currently working on a testsuite using Python's unittest library. This
works all good and fine, but there's one thing where I haven't seen an
elegant solution to yet, and that is the ordering. Currently, it takes all
classes and orders them alphabetically and then takes all test functions
therein and runs those alphabetically, too. However, sometimes it doesn't
make sense to run test_bar() if test_foo() already failed, because they
basically build upon each other. However, test_bar() is still run first,
and test_foo() second.

What I sometimes do is to simply number them, like test_1_foo() and
test_2_bar(), but that seems ugly. I'm not even looking for a way to
express complicated relations between tests, but is there a less ugly way
to explicitly order them?

Cheers!

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list