test-unit 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +30 -0
- data/Manifest.txt +20 -12
- data/README.txt +28 -12
- data/Rakefile +5 -0
- data/TODO +1 -0
- data/html/classic.html +15 -0
- data/html/index.html +25 -0
- data/html/index.html.ja +27 -0
- data/html/test-unit-classic.png +0 -0
- data/lib/test/unit.rb +62 -0
- data/lib/test/unit/assertions.rb +350 -66
- data/lib/test/unit/autorunner.rb +68 -13
- data/lib/test/unit/collector/load.rb +1 -1
- data/lib/test/unit/color-scheme.rb +85 -0
- data/lib/test/unit/color.rb +40 -5
- data/lib/test/unit/diff.rb +14 -0
- data/lib/test/unit/fixture.rb +2 -2
- data/lib/test/unit/runner/console.rb +8 -2
- data/lib/test/unit/testcase.rb +86 -2
- data/lib/test/unit/ui/console/testrunner.rb +51 -26
- data/lib/test/unit/version.rb +1 -1
- data/sample/test_user.rb +22 -0
- data/test/collector/{test_descendant.rb → test-descendant.rb} +0 -0
- data/test/collector/{test_load.rb → test-load.rb} +1 -1
- data/test/{test_attribute.rb → test-attribute.rb} +0 -0
- data/test/test-color-scheme.rb +55 -0
- data/test/{test_color.rb → test-color.rb} +10 -0
- data/test/{test_diff.rb → test-diff.rb} +0 -0
- data/test/{test_emacs_runner.rb → test-emacs-runner.rb} +0 -0
- data/test/test-fixture.rb +287 -0
- data/test/{test_notification.rb → test-notification.rb} +4 -4
- data/test/{test_omission.rb → test-omission.rb} +6 -6
- data/test/{test_pending.rb → test-pending.rb} +6 -6
- data/test/{test_priority.rb → test-priority.rb} +0 -0
- data/test/test_assertions.rb +366 -63
- data/test/test_testcase.rb +48 -0
- data/test/{testunit_test_util.rb → testunit-test-util.rb} +1 -1
- metadata +27 -29
- data/test/test_fixture.rb +0 -275
data/test/test_testcase.rb
CHANGED
@@ -420,6 +420,54 @@ module Test
|
|
420
420
|
check("Should not be interrupted", !success_test.interrupted?)
|
421
421
|
end
|
422
422
|
|
423
|
+
def test_inherited_test_should_be_ignored
|
424
|
+
test_case = Class.new(TestCase) do
|
425
|
+
def test_nothing
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
sub_test_case = Class.new(test_case) do
|
430
|
+
def test_fail
|
431
|
+
flunk
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
assert_nothing_thrown do
|
436
|
+
test_case.new("test_nothing")
|
437
|
+
end
|
438
|
+
|
439
|
+
assert_nothing_thrown do
|
440
|
+
sub_test_case.new("test_fail")
|
441
|
+
end
|
442
|
+
|
443
|
+
assert_throw(:invalid_test) do
|
444
|
+
sub_test_case.new("test_nothing")
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
def test_mixin_test_should_not_be_ignored
|
449
|
+
test_module = Module.new do
|
450
|
+
def test_nothing
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
455
|
+
include test_module
|
456
|
+
|
457
|
+
def test_fail
|
458
|
+
flunk
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
assert_nothing_thrown do
|
463
|
+
test_case.new("test_nothing")
|
464
|
+
end
|
465
|
+
|
466
|
+
assert_nothing_thrown do
|
467
|
+
test_case.new("test_fail")
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
423
471
|
private
|
424
472
|
def check(message, passed)
|
425
473
|
add_assertion
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -10,19 +10,20 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-11-09 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: hoe
|
18
|
+
type: :development
|
18
19
|
version_requirement:
|
19
20
|
version_requirements: !ruby/object:Gem::Requirement
|
20
21
|
requirements:
|
21
22
|
- - ">="
|
22
23
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
24
|
+
version: 1.8.2
|
24
25
|
version:
|
25
|
-
description: Test::Unit
|
26
|
+
description: Test::Unit 2.x - Improved version of Test::Unit bundled in Ruby 1.8.x. Ruby 1.9.x bundles miniunit not Test::Unit. Test::Unit bundled in Ruby 1.8.x had not been improved but unbundled Test::Unit (Test::Unit 2.x) will be improved actively.
|
26
27
|
email:
|
27
28
|
- kou@cozmixng.org
|
28
29
|
- ryand-ruby@zenspider.com
|
@@ -39,7 +40,12 @@ files:
|
|
39
40
|
- Manifest.txt
|
40
41
|
- README.txt
|
41
42
|
- Rakefile
|
43
|
+
- TODO
|
42
44
|
- bin/testrb
|
45
|
+
- html/classic.html
|
46
|
+
- html/index.html
|
47
|
+
- html/index.html.ja
|
48
|
+
- html/test-unit-classic.png
|
43
49
|
- lib/test/unit.rb
|
44
50
|
- lib/test/unit/assertionfailederror.rb
|
45
51
|
- lib/test/unit/assertions.rb
|
@@ -50,6 +56,7 @@ files:
|
|
50
56
|
- lib/test/unit/collector/dir.rb
|
51
57
|
- lib/test/unit/collector/load.rb
|
52
58
|
- lib/test/unit/collector/objectspace.rb
|
59
|
+
- lib/test/unit/color-scheme.rb
|
53
60
|
- lib/test/unit/color.rb
|
54
61
|
- lib/test/unit/diff.rb
|
55
62
|
- lib/test/unit/error.rb
|
@@ -79,28 +86,30 @@ files:
|
|
79
86
|
- sample/subtracter.rb
|
80
87
|
- sample/tc_adder.rb
|
81
88
|
- sample/tc_subtracter.rb
|
89
|
+
- sample/test_user.rb
|
82
90
|
- sample/ts_examples.rb
|
83
|
-
- test/collector/
|
91
|
+
- test/collector/test-descendant.rb
|
92
|
+
- test/collector/test-load.rb
|
84
93
|
- test/collector/test_dir.rb
|
85
|
-
- test/collector/test_load.rb
|
86
94
|
- test/collector/test_objectspace.rb
|
87
95
|
- test/run-test.rb
|
96
|
+
- test/test-attribute.rb
|
97
|
+
- test/test-color-scheme.rb
|
98
|
+
- test/test-color.rb
|
99
|
+
- test/test-diff.rb
|
100
|
+
- test/test-emacs-runner.rb
|
101
|
+
- test/test-fixture.rb
|
102
|
+
- test/test-notification.rb
|
103
|
+
- test/test-omission.rb
|
104
|
+
- test/test-pending.rb
|
105
|
+
- test/test-priority.rb
|
88
106
|
- test/test_assertions.rb
|
89
|
-
- test/test_attribute.rb
|
90
|
-
- test/test_color.rb
|
91
|
-
- test/test_diff.rb
|
92
|
-
- test/test_emacs_runner.rb
|
93
107
|
- test/test_error.rb
|
94
108
|
- test/test_failure.rb
|
95
|
-
- test/test_fixture.rb
|
96
|
-
- test/test_notification.rb
|
97
|
-
- test/test_omission.rb
|
98
|
-
- test/test_pending.rb
|
99
|
-
- test/test_priority.rb
|
100
109
|
- test/test_testcase.rb
|
101
110
|
- test/test_testresult.rb
|
102
111
|
- test/test_testsuite.rb
|
103
|
-
- test/
|
112
|
+
- test/testunit-test-util.rb
|
104
113
|
- test/ui/test_testrunmediator.rb
|
105
114
|
- test/util/test_backtracefilter.rb
|
106
115
|
- test/util/test_observable.rb
|
@@ -128,31 +137,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
137
|
requirements: []
|
129
138
|
|
130
139
|
rubyforge_project: test-unit
|
131
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.2.0
|
132
141
|
signing_key:
|
133
142
|
specification_version: 2
|
134
|
-
summary: Test::Unit
|
143
|
+
summary: Test::Unit 2.x - Improved version of Test::Unit bundled in Ruby 1.8.x
|
135
144
|
test_files:
|
136
|
-
- test/test_pending.rb
|
137
145
|
- test/test_testcase.rb
|
138
|
-
- test/test_color.rb
|
139
146
|
- test/test_failure.rb
|
140
|
-
- test/test_diff.rb
|
141
|
-
- test/test_fixture.rb
|
142
147
|
- test/collector/test_objectspace.rb
|
143
|
-
- test/collector/test_load.rb
|
144
148
|
- test/collector/test_dir.rb
|
145
|
-
- test/collector/test_descendant.rb
|
146
|
-
- test/test_attribute.rb
|
147
|
-
- test/test_emacs_runner.rb
|
148
149
|
- test/test_testsuite.rb
|
149
150
|
- test/test_assertions.rb
|
150
151
|
- test/util/test_observable.rb
|
151
152
|
- test/util/test_procwrapper.rb
|
152
153
|
- test/util/test_backtracefilter.rb
|
153
154
|
- test/ui/test_testrunmediator.rb
|
154
|
-
- test/test_priority.rb
|
155
155
|
- test/test_testresult.rb
|
156
|
-
- test/test_omission.rb
|
157
156
|
- test/test_error.rb
|
158
|
-
- test/test_notification.rb
|
data/test/test_fixture.rb
DELETED
@@ -1,275 +0,0 @@
|
|
1
|
-
class TestUnitFixture < Test::Unit::TestCase
|
2
|
-
def test_setup_without_option
|
3
|
-
test_case = assert_setup([:setup,
|
4
|
-
:custom_setup_method0,
|
5
|
-
:custom_setup_method1,
|
6
|
-
:custom_setup_method3],
|
7
|
-
[])
|
8
|
-
assert_inherited_setup([:setup,
|
9
|
-
:custom_setup_method0,
|
10
|
-
:custom_setup_method1,
|
11
|
-
:custom_setup_method3],
|
12
|
-
test_case)
|
13
|
-
assert_inherited_setup([:setup], nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_setup_with_before_option
|
17
|
-
test_case = assert_setup([:custom_setup_method3,
|
18
|
-
:custom_setup_method0,
|
19
|
-
:custom_setup_method1,
|
20
|
-
:setup],
|
21
|
-
[[{:before => :append}],
|
22
|
-
[{:before => :append}],
|
23
|
-
[{:before => :prepend}],
|
24
|
-
[{:before => :prepend}]])
|
25
|
-
assert_inherited_setup([:custom_setup_method3,
|
26
|
-
:custom_setup_method0,
|
27
|
-
:custom_setup_method1,
|
28
|
-
:setup],
|
29
|
-
test_case)
|
30
|
-
assert_inherited_setup([:setup], nil)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_setup_with_after_option
|
34
|
-
test_case = assert_setup([:setup,
|
35
|
-
:custom_setup_method3,
|
36
|
-
:custom_setup_method0,
|
37
|
-
:custom_setup_method1],
|
38
|
-
[[{:after => :append}],
|
39
|
-
[{:after => :append}],
|
40
|
-
[{:after => :prepend}],
|
41
|
-
[{:after => :prepend}]])
|
42
|
-
assert_inherited_setup([:setup,
|
43
|
-
:custom_setup_method3,
|
44
|
-
:custom_setup_method0,
|
45
|
-
:custom_setup_method1],
|
46
|
-
test_case)
|
47
|
-
assert_inherited_setup([:setup], nil)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_setup_with_invalid_option
|
51
|
-
assert_invalid_setup_option(:unknown => true)
|
52
|
-
assert_invalid_setup_option(:before => :unknown)
|
53
|
-
assert_invalid_setup_option(:after => :unknown)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_teardown_without_option
|
57
|
-
test_case = assert_teardown([:custom_teardown_method3,
|
58
|
-
:custom_teardown_method1,
|
59
|
-
:custom_teardown_method0,
|
60
|
-
:teardown],
|
61
|
-
[])
|
62
|
-
assert_inherited_teardown([:custom_teardown_method3,
|
63
|
-
:custom_teardown_method1,
|
64
|
-
:custom_teardown_method0,
|
65
|
-
:teardown],
|
66
|
-
test_case)
|
67
|
-
assert_inherited_teardown([:teardown], nil)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_teardown_with_before_option
|
71
|
-
test_case = assert_teardown([:custom_teardown_method3,
|
72
|
-
:custom_teardown_method0,
|
73
|
-
:custom_teardown_method1,
|
74
|
-
:teardown],
|
75
|
-
[[{:before => :append}],
|
76
|
-
[{:before => :append}],
|
77
|
-
[{:before => :prepend}],
|
78
|
-
[{:before => :prepend}]])
|
79
|
-
assert_inherited_teardown([:custom_teardown_method3,
|
80
|
-
:custom_teardown_method0,
|
81
|
-
:custom_teardown_method1,
|
82
|
-
:teardown],
|
83
|
-
test_case)
|
84
|
-
assert_inherited_teardown([:teardown], nil)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_teardown_with_after_option
|
88
|
-
test_case = assert_teardown([:teardown,
|
89
|
-
:custom_teardown_method3,
|
90
|
-
:custom_teardown_method0,
|
91
|
-
:custom_teardown_method1],
|
92
|
-
[[{:after => :append}],
|
93
|
-
[{:after => :append}],
|
94
|
-
[{:after => :prepend}],
|
95
|
-
[{:after => :prepend}]])
|
96
|
-
assert_inherited_teardown([:teardown,
|
97
|
-
:custom_teardown_method3,
|
98
|
-
:custom_teardown_method0,
|
99
|
-
:custom_teardown_method1],
|
100
|
-
test_case)
|
101
|
-
assert_inherited_teardown([:teardown], nil)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_teardown_with_invalid_option
|
105
|
-
assert_invalid_teardown_option(:unknown => true)
|
106
|
-
assert_invalid_teardown_option(:before => :unknown)
|
107
|
-
assert_invalid_teardown_option(:after => :unknown)
|
108
|
-
end
|
109
|
-
|
110
|
-
private
|
111
|
-
def assert_setup(expected, setup_options)
|
112
|
-
called = []
|
113
|
-
test_case = Class.new(Test::Unit::TestCase) do
|
114
|
-
@@called = called
|
115
|
-
def setup
|
116
|
-
@@called << :setup
|
117
|
-
end
|
118
|
-
|
119
|
-
setup(*(setup_options[0] || []))
|
120
|
-
def custom_setup_method0
|
121
|
-
@@called << :custom_setup_method0
|
122
|
-
end
|
123
|
-
|
124
|
-
def custom_setup_method1
|
125
|
-
@@called << :custom_setup_method1
|
126
|
-
end
|
127
|
-
setup(*[:custom_setup_method1, *(setup_options[1] || [])])
|
128
|
-
|
129
|
-
setup(*(setup_options[2] || []))
|
130
|
-
def custom_setup_method2
|
131
|
-
@@called << :custom_setup_method2
|
132
|
-
end
|
133
|
-
unregister_setup(:custom_setup_method2)
|
134
|
-
|
135
|
-
setup(*(setup_options[3] || []))
|
136
|
-
def custom_setup_method3
|
137
|
-
@@called << :custom_setup_method3
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_nothing
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
test_case.new("test_nothing").run(Test::Unit::TestResult.new) {}
|
145
|
-
assert_equal(expected, called)
|
146
|
-
test_case
|
147
|
-
end
|
148
|
-
|
149
|
-
def assert_inherited_setup(expected, parent)
|
150
|
-
called = []
|
151
|
-
inherited_test_case = Class.new(parent || Test::Unit::TestCase) do
|
152
|
-
@@called = called
|
153
|
-
def setup
|
154
|
-
@@called << :setup
|
155
|
-
end
|
156
|
-
|
157
|
-
def custom_setup_method0
|
158
|
-
@@called << :custom_setup_method0
|
159
|
-
end
|
160
|
-
|
161
|
-
def custom_setup_method1
|
162
|
-
@@called << :custom_setup_method1
|
163
|
-
end
|
164
|
-
|
165
|
-
def custom_setup_method2
|
166
|
-
@@called << :custom_setup_method2
|
167
|
-
end
|
168
|
-
|
169
|
-
def custom_setup_method3
|
170
|
-
@@called << :custom_setup_method3
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_nothing
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
inherited_test_case.new("test_nothing").run(Test::Unit::TestResult.new) {}
|
178
|
-
assert_equal(expected, called)
|
179
|
-
end
|
180
|
-
|
181
|
-
def assert_teardown(expected, teardown_options)
|
182
|
-
called = []
|
183
|
-
test_case = Class.new(Test::Unit::TestCase) do
|
184
|
-
@@called = called
|
185
|
-
def teardown
|
186
|
-
@@called << :teardown
|
187
|
-
end
|
188
|
-
|
189
|
-
teardown(*(teardown_options[0] || []))
|
190
|
-
def custom_teardown_method0
|
191
|
-
@@called << :custom_teardown_method0
|
192
|
-
end
|
193
|
-
|
194
|
-
def custom_teardown_method1
|
195
|
-
@@called << :custom_teardown_method1
|
196
|
-
end
|
197
|
-
teardown(*[:custom_teardown_method1, *(teardown_options[1] || [])])
|
198
|
-
|
199
|
-
teardown(*(teardown_options[2] || []))
|
200
|
-
def custom_teardown_method2
|
201
|
-
@@called << :custom_teardown_method2
|
202
|
-
end
|
203
|
-
unregister_teardown(:custom_teardown_method2)
|
204
|
-
|
205
|
-
teardown(*(teardown_options[3] || []))
|
206
|
-
def custom_teardown_method3
|
207
|
-
@@called << :custom_teardown_method3
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_nothing
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
test_case.new("test_nothing").run(Test::Unit::TestResult.new) {}
|
215
|
-
assert_equal(expected, called)
|
216
|
-
test_case
|
217
|
-
end
|
218
|
-
|
219
|
-
def assert_inherited_teardown(expected, parent)
|
220
|
-
called = []
|
221
|
-
inherited_test_case = Class.new(parent || Test::Unit::TestCase) do
|
222
|
-
@@called = called
|
223
|
-
def teardown
|
224
|
-
@@called << :teardown
|
225
|
-
end
|
226
|
-
|
227
|
-
def custom_teardown_method0
|
228
|
-
@@called << :custom_teardown_method0
|
229
|
-
end
|
230
|
-
|
231
|
-
def custom_teardown_method1
|
232
|
-
@@called << :custom_teardown_method1
|
233
|
-
end
|
234
|
-
|
235
|
-
def custom_teardown_method2
|
236
|
-
@@called << :custom_teardown_method2
|
237
|
-
end
|
238
|
-
|
239
|
-
def custom_teardown_method3
|
240
|
-
@@called << :custom_teardown_method3
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_nothing
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
inherited_test_case.new("test_nothing").run(Test::Unit::TestResult.new) {}
|
248
|
-
assert_equal(expected, called)
|
249
|
-
end
|
250
|
-
|
251
|
-
def assert_invalid_option(fixture_type, option)
|
252
|
-
exception = assert_raise(ArgumentError) do
|
253
|
-
Class.new(Test::Unit::TestCase) do
|
254
|
-
def test_nothing
|
255
|
-
end
|
256
|
-
|
257
|
-
send(fixture_type, option)
|
258
|
-
def fixture
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
assert_equal("must be {:before => :prepend}, {:before => :append}, " +
|
263
|
-
"{:after => :prepend} or {:after => :append}" +
|
264
|
-
": #{option.inspect}",
|
265
|
-
exception.message)
|
266
|
-
end
|
267
|
-
|
268
|
-
def assert_invalid_setup_option(option)
|
269
|
-
assert_invalid_option(:setup, option)
|
270
|
-
end
|
271
|
-
|
272
|
-
def assert_invalid_teardown_option(option)
|
273
|
-
assert_invalid_option(:teardown, option)
|
274
|
-
end
|
275
|
-
end
|