From: Jeff - Burly Systems Date: 2007-09-06T02:06:54+09:00 Subject: Re: DB connection setup for Unit Testing Somewhat lame, but this might do what you're looking for: 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 def test_zzzzzz_should_be_the_last_test_run_due_to_zzzzzz @@done_with_db = true end # continue on with tests that use @@db .... Jeff On 8/31/07, Max Russell wrote: > I am trying to take a test-driven approach to a script I am writing. > > The script needs to connect to SQLServer using DBI. > Currently it looks like this: > > > class BurndownTests < Test::Unit::TestCase > > def setup > db = DBI.connect("DBI:ODBC:driver={SQL > Server};Server=INPSESVER1;Database=RMT;Trusted_Connection=yes;") > end > > def teardown > db.disconnect > end > > def test_connectrmtrack > pass > end > > def test_export_schedule > pass > end > > def test_format_datecols > pass > end > > def test_count_resolutions > pass > end > > def test_dumptofile > pass > end > > end > > The issue with this is that using setup like this, from what I > understand is used for each new test method I add. As I want to connect, > test the connection and then run tests which have a reliance on the > connection being established, how can I do a onetime setup and then test > this? > -- > Posted via http://www.ruby-forum.com/. > >