From: Ryan Davis Date: 2007-09-08T15:46:21+09:00 Subject: Re: DB connection setup for Unit Testing On Sep 5, 2007, at 10:06 , Jeff - Burly Systems wrote: > class BurndownTests < Test::Unit::TestCase > > @@db = nil > @@done_with_db = false > > def setup > db =DBI.connect(.......) if not @@db > end > > def teardown > db.disconnect if @@done_with_db > end This is what I use for such types of things: $db = DBI... at_exit { at_exit { $db.disconnect } } # guaranteed to run AFTER test/ unit is done # ...stuff...