From: Matt Armstrong Date: 2003-01-28T04:42:48+09:00 Subject: Re: Test::Unit -> order of tests? ahoward writes: > On Tue, 28 Jan 2003, Chad Fowler wrote: > >> I humbly disagree with this. If the order of the tests is >> guaranteed, it would promote temporal coupling between the test >> cases. It's better to let each "test..." method stand alone >> without dependencies on the other methods. > > this may be true _most_ of the time, but there are cases where it's > too inconvenient to decouple tests from their order, for example, i > have a test suite for [description of interrelated tests snipped] [...] The point of the TestCase class is to make it easy to set up a series of different tests that all need the same initial test environment. So in this case, what you're describing is a test case with a single test that starts with a blank database. To implement this, I would suggest renaming all your test_XXX methods to subtest_XXX and have a single test_all method that calls the subtest_XXX methods in the proper order. Have your setup method create the database and your teardown method delete it. This is better for many reasons: - you can no longer run your tests out of order, since Test::Unit only allows you to run individual test_ methods, not subtest_ methods. - the order of your sub-tests are explicit and understandable (not relying on non-obvious magical properties like the sort order of the method names or the declaration order within the class). - fits better into the intent of the TestCase class -- one that sets up a consistent environment in which every test_ method is run.