In article <87is5jb46q.fsf / serein.a02.aist.go.jp>,
  Tanaka Akira <akr / m17n.org> writes:

> test/unit doesn't rescue a Exception in a test method, as follows.

How about this patch?

Index: lib/test/unit/testcase.rb
===================================================================
RCS file: /src/ruby/lib/test/unit/testcase.rb,v
retrieving revision 1.7
diff -u -p -r1.7 testcase.rb
--- lib/test/unit/testcase.rb	4 Aug 2006 18:05:45 -0000	1.7
+++ lib/test/unit/testcase.rb	2 Sep 2006 03:06:34 -0000
@@ -70,7 +70,7 @@ module Test
           __send__(@method_name)
         rescue AssertionFailedError => e
           add_failure(e.message, e.backtrace)
-        rescue StandardError, ScriptError
+        rescue Exception
           add_error($!)
         ensure
           begin

The patch makes test/unit to count all exception as follows.

% cat a.rb 
require 'test/unit'

class T < Test::Unit::TestCase
  def test_a
    raise Exception
  end
end
% ./ruby -Ilib a.rb
Loaded suite a
Started
E
Finished in 0.000373 seconds.

  1) Error:
test_a(T):
Exception: Exception
    a.rb:5:in `test_a'

1 tests, 0 assertions, 0 failures, 1 errors

test/unit exits prematurely without the patch.

% ./ruby a.rb      
Loaded suite a
Started
a.rb:5:in `test_a': Exception (Exception)
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testcase.rb:70:in `__send__'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testcase.rb:70:in `Test::Unit::TestCase#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testsuite.rb:34:in `Test::Unit::TestSuite#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testsuite.rb:33:in `Array#each'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testsuite.rb:33:in `Test::Unit::TestSuite#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testsuite.rb:34:in `Test::Unit::TestSuite#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testsuite.rb:33:in `Array#each'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/testsuite.rb:33:in `Test::Unit::TestSuite#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/ui/testrunnermediator.rb:46:in `Test::Unit::UI::TestRunnerMediator#run_suite'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/ui/console/testrunner.rb:67:in `start_mediator'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/ui/console/testrunner.rb:41:in `Test::Unit::UI::Console::TestRunner#start'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/ui/testrunnerutilities.rb:29:in `Test::Unit::UI::TestRunnerUtilities#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/autorunner.rb:200:in `Test::Unit::AutoRunner#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit/autorunner.rb:13:in `Test::Unit::AutoRunner#run'
        from /home/akr/ruby/19/lib/ruby/1.9/test/unit.rb:278
        from a.rb:4
        from a.rb:4
-- 
Tanaka Akira