test-unit/test/test_testcase.rb in activeldap-1.0.1 vs test-unit/test/test_testcase.rb in activeldap-1.0.2

- old
+ new

@@ -265,11 +265,11 @@ end def test_re_raise_exception test_case = Class.new(TestCase) do def test_raise_interrupt - raise Interrupt + raise Interrupt, "from test" end end test = test_case.new("test_raise_interrupt") begin @@ -340,11 +340,11 @@ def test_pass_through_error_on_startup test_case = Class.new(TestCase) do class << self def startup - raise Interrupt + raise Interrupt, "from startup" end end def test_nothing end @@ -381,11 +381,11 @@ def test_pass_through_error_on_shutdown test_case = Class.new(TestCase) do class << self def shutdown - raise Interrupt + raise Interrupt, "from shutdown" end end def test_nothing end @@ -396,9 +396,76 @@ test_suite.run(TestResult.new) {} check("Should not be reached", false) rescue Exception check("Interrupt should be passed through: #{$!}", Interrupt === $!) + end + end + + def test_interrupted + test_case = Class.new(TestCase) do + def test_fail + flunk + end + + def test_nothing + end + end + + failed_test = test_case.new(:test_fail) + failed_test.run(TestResult.new) {} + check("Should be interrupted", failed_test.interrupted?) + + success_test = test_case.new(:test_nothing) + success_test.run(TestResult.new) {} + check("Should not be interrupted", !success_test.interrupted?) + end + + def test_inherited_test_should_be_ignored + test_case = Class.new(TestCase) do + def test_nothing + end + end + + sub_test_case = Class.new(test_case) do + def test_fail + flunk + end + end + + assert_nothing_thrown do + test_case.new("test_nothing") + end + + assert_nothing_thrown do + sub_test_case.new("test_fail") + end + + assert_throw(:invalid_test) do + sub_test_case.new("test_nothing") + end + end + + def test_mixin_test_should_not_be_ignored + test_module = Module.new do + def test_nothing + end + end + + test_case = Class.new(Test::Unit::TestCase) do + include test_module + + def test_fail + flunk + end + end + + assert_nothing_thrown do + test_case.new("test_nothing") + end + + assert_nothing_thrown do + test_case.new("test_fail") end end private def check(message, passed)