From: Michael Garriss Date: 2003-01-28T03:43:44+09:00 Subject: Re: Test::Unit -> order of tests? Concider the following simple example code: require 'dbi' class DB_User def initialize( dns, user, pass ) @dbh = DBI::connect( dns, user, pass ) end def create_user_table @dbh.execute "CREATE TABLE my_user ( id BIGINT NOT NULL PRIMARY KEY, username VARCHAR(24) NOT NULL, password VARCHAR(24) NOT NULL, email VARCHAR(64) )" end def drop_user_table @dbh.execute( "DROP TABLE my_user" ) end end Lets say I want to test create_user_table and drop_user_table seperatly. A possible solution: require 'test/unit' require 'db_user' class TC_DB_User < Test::Unit::TestCase DNS = 'dbi:Pg:tiamat' USER = 'postgres' PASS = nil def test_connection begin @tdb = Tiamat::DB_User.new( DNS, USER, PASS ) rescue DBI::Error assert( false, 'Error getting connection' ) end end def test_create_table test_connection # !!!!!! begin @tdb.create_user_table rescue DBI::ProgrammingError assert( false, 'Error creating user table' ) end end def test_drop_table test_connection # !!!!!! test_create_table # !!!!!! begin @tdb.drop_user_table rescue DBI::ProgrammingError assert( false, 'Error creating user table' ) end end end The tests that depend on other tests are just run from the tests that need them. Is this bad practice?? -Mike