@@ -18,11 +18,9 @@ def options
18
18
end
19
19
end
20
20
21
- def test_callback_with_exception
21
+ def test_standard_error_raised_within_setup_callback_is_puked
22
22
tc = Class . new ( TestCase ) do
23
- def self . name
24
- nil
25
- end
23
+ def self . name ; nil ; end
26
24
27
25
setup :bad_callback
28
26
def bad_callback ; raise 'oh noes' end
@@ -41,11 +39,9 @@ def test_true; assert true end
41
39
assert_equal 'oh noes' , exception . message
42
40
end
43
41
44
- def test_teardown_callback_with_exception
42
+ def test_standard_error_raised_within_teardown_callback_is_puked
45
43
tc = Class . new ( TestCase ) do
46
- def self . name
47
- nil
48
- end
44
+ def self . name ; nil ; end
49
45
50
46
teardown :bad_callback
51
47
def bad_callback ; raise 'oh noes' end
@@ -63,5 +59,51 @@ def test_true; assert true end
63
59
assert_equal test_name , name
64
60
assert_equal 'oh noes' , exception . message
65
61
end
62
+
63
+ def test_passthrough_exception_raised_within_test_method_is_not_rescued
64
+ tc = Class . new ( TestCase ) do
65
+ def self . name ; nil ; end
66
+
67
+ def test_which_raises_interrupt ; raise Interrupt ; end
68
+ end
69
+
70
+ test_name = 'test_which_raises_interrupt'
71
+ fr = FakeRunner . new
72
+
73
+ test = tc . new test_name
74
+ assert_raises ( Interrupt ) { test . run fr }
75
+ end
76
+
77
+ def test_passthrough_exception_raised_within_setup_callback_is_not_rescued
78
+ tc = Class . new ( TestCase ) do
79
+ def self . name ; nil ; end
80
+
81
+ setup :callback_which_raises_interrupt
82
+ def callback_which_raises_interrupt ; raise Interrupt ; end
83
+ def test_true ; assert true end
84
+ end
85
+
86
+ test_name = 'test_true'
87
+ fr = FakeRunner . new
88
+
89
+ test = tc . new test_name
90
+ assert_raises ( Interrupt ) { test . run fr }
91
+ end
92
+
93
+ def test_passthrough_exception_raised_within_teardown_callback_is_not_rescued
94
+ tc = Class . new ( TestCase ) do
95
+ def self . name ; nil ; end
96
+
97
+ teardown :callback_which_raises_interrupt
98
+ def callback_which_raises_interrupt ; raise Interrupt ; end
99
+ def test_true ; assert true end
100
+ end
101
+
102
+ test_name = 'test_true'
103
+ fr = FakeRunner . new
104
+
105
+ test = tc . new test_name
106
+ assert_raises ( Interrupt ) { test . run fr }
107
+ end
66
108
end
67
109
end
0 commit comments