Hi all,

Here are two patches that add startup and shutdown methods to 
Test::Unit. Unlike setup and teardown, they run once per test suite, not 
per test.

Regards,

Dan

--- testcase.orig       Tue Mar  4 14:33:21 2008
+++ testcase.rb Tue Mar  4 14:38:10 2008
@@ -95,6 +95,16 @@
          yield(FINISHED, name)
        end

+      # Called once before each test suite is run. Can be used for one time
+      # set up of fixture information.
+      def startup
+      end
+
+      # Called once after the test suite runs. Can be used for one time
+      # clean up up of fixture information.
+      def shutdown
+      end
+
        # Called before every test method runs. Can be used
        # to set up fixture information.
        def setup

--- testsuite.orig      Tue Mar  4 14:33:28 2008
+++ testsuite.rb        Tue Mar  4 14:34:04 2008
@@ -30,9 +30,33 @@
        # TestSuite.
        def run(result, &progress_block)
          yield(STARTED, name)
-        @tests.each do |test|
+
+        @tests.each_with_index do |test, index|
+          begin
+            if index == 0 && test.respond_to?(:startup)
+               test.startup
+            end
+          rescue Exception
+            if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? 
$!.class
+               raise
+            end
+            test.send(:add_error, $!) # Private method
+          end
+
            test.run(result, &progress_block)
+
+          begin
+            if index == @tests.length - 1 && test.respond_to?(:shutdown)
+               test.shutdown
+            end
+          rescue Exception
+            if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? 
$!.class
+               raise
+            end
+            test.send(:add_error, $!) # Private method
+          end
          end
+
          yield(FINISHED, name)
        end