From: Masaki Suketa Date: 2001-01-13T08:53:57+09:00 Subject: [ruby-talk:9227] Re: using RUnit's setup and teardown methods Hello Robert, In message "[ruby-talk:9024] Re: using RUnit's setup and teardown methods" on 01/01/10, Robert Feldt writes: > > You also use setup methods to do things like tidy up external > > resources (databases, files and the like). > > > I think I read somewhere that there is a good reason why a unit testing > framework shouldn't have setup_once and teardown_once for tidying up > external resources but I fail to remember the reason. Anyone knows the > reason? If not why dont we add setup_once to RubyUnit? I don't know the reason why testing framework shouldn't have setup_once and teardown_once and I want to know, too. But I know the reason why RubyUnit has no these methods. Because JUnit has no these methods. (I referenced JUnit when I implemented RubyUnit.) And RubyUnit has RUNIT::Ext::TestSetup module like as JUnit. This module provides the same functionality as setup_once and teardown_once. require 'runit/testcase' require 'runit/cui/testrunner' require 'runit/ext/testsetup' class TestFoo < RUNIT::TestCase def setup puts "\nTestFoo#setup" end def test_a puts "running TestFoo#test_a" end def test_b puts "running TestFoo#test_b" end def teardown puts "\nTestFoo#teardown" end end class OnceSetupTeardown include RUNIT::EXT::TestSetup def setup puts "\nOnceSetupTeardown#setup" end def teardown puts "\nOnceSetupTeardown#teardown" end end RUNIT::CUI::TestRunner.quiet_mode = true RUNIT::CUI::TestRunner.run(OnceSetupTeardown.new(TestFoo.suite)) But I think TestSetup module is not convenient because OnceSetupTeardown#setup(teardown) can not share (or access) TestFoo instance variable(test fixture). Thank you. Masaki Suketa