test-unit 3.1.5 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/BSDL +24 -0
  3. data/COPYING +41 -41
  4. data/README.md +24 -17
  5. data/Rakefile +21 -24
  6. data/doc/text/getting-started.md +246 -0
  7. data/doc/text/news.md +797 -56
  8. data/lib/test/unit/assertion-failed-error.rb +35 -0
  9. data/lib/test/unit/assertions.rb +542 -220
  10. data/lib/test/unit/attribute.rb +78 -4
  11. data/lib/test/unit/auto-runner-loader.rb +17 -0
  12. data/lib/test/unit/autorunner.rb +175 -78
  13. data/lib/test/unit/code-snippet-fetcher.rb +7 -7
  14. data/lib/test/unit/collector/descendant.rb +1 -0
  15. data/lib/test/unit/collector/dir.rb +4 -2
  16. data/lib/test/unit/collector/load.rb +25 -15
  17. data/lib/test/unit/collector/objectspace.rb +1 -0
  18. data/lib/test/unit/collector.rb +31 -0
  19. data/lib/test/unit/color-scheme.rb +29 -2
  20. data/lib/test/unit/data-sets.rb +127 -0
  21. data/lib/test/unit/data.rb +121 -12
  22. data/lib/test/unit/diff.rb +10 -11
  23. data/lib/test/unit/fixture.rb +77 -27
  24. data/lib/test/unit/notification.rb +9 -7
  25. data/lib/test/unit/omission.rb +34 -31
  26. data/lib/test/unit/pending.rb +12 -11
  27. data/lib/test/unit/priority.rb +7 -5
  28. data/lib/test/unit/runner/console.rb +20 -1
  29. data/lib/test/unit/test-suite-creator.rb +30 -9
  30. data/lib/test/unit/testcase.rb +349 -196
  31. data/lib/test/unit/testresult.rb +7 -0
  32. data/lib/test/unit/testsuite.rb +1 -1
  33. data/lib/test/unit/ui/console/testrunner.rb +171 -60
  34. data/lib/test/unit/ui/emacs/testrunner.rb +5 -5
  35. data/lib/test/unit/ui/testrunnermediator.rb +9 -7
  36. data/lib/test/unit/util/backtracefilter.rb +17 -5
  37. data/lib/test/unit/util/memory-usage.rb +47 -0
  38. data/lib/test/unit/util/observable.rb +2 -2
  39. data/lib/test/unit/util/output.rb +5 -4
  40. data/lib/test/unit/util/procwrapper.rb +4 -4
  41. data/lib/test/unit/version.rb +1 -1
  42. data/lib/test/unit/warning.rb +3 -0
  43. data/lib/test/unit.rb +177 -161
  44. data/lib/test-unit.rb +2 -17
  45. metadata +20 -94
  46. data/GPL +0 -339
  47. data/LGPL +0 -502
  48. data/test/collector/test-descendant.rb +0 -178
  49. data/test/collector/test-load.rb +0 -442
  50. data/test/collector/test_dir.rb +0 -406
  51. data/test/collector/test_objectspace.rb +0 -100
  52. data/test/fixtures/header-label.csv +0 -3
  53. data/test/fixtures/header-label.tsv +0 -3
  54. data/test/fixtures/header.csv +0 -3
  55. data/test/fixtures/header.tsv +0 -3
  56. data/test/fixtures/no-header.csv +0 -2
  57. data/test/fixtures/no-header.tsv +0 -2
  58. data/test/fixtures/plus.csv +0 -3
  59. data/test/run-test.rb +0 -22
  60. data/test/test-assertions.rb +0 -2157
  61. data/test/test-attribute-matcher.rb +0 -38
  62. data/test/test-attribute.rb +0 -123
  63. data/test/test-code-snippet.rb +0 -37
  64. data/test/test-color-scheme.rb +0 -82
  65. data/test/test-color.rb +0 -47
  66. data/test/test-data.rb +0 -281
  67. data/test/test-diff.rb +0 -518
  68. data/test/test-emacs-runner.rb +0 -60
  69. data/test/test-error.rb +0 -26
  70. data/test/test-failure.rb +0 -33
  71. data/test/test-fault-location-detector.rb +0 -163
  72. data/test/test-fixture.rb +0 -659
  73. data/test/test-notification.rb +0 -33
  74. data/test/test-omission.rb +0 -81
  75. data/test/test-pending.rb +0 -70
  76. data/test/test-priority.rb +0 -173
  77. data/test/test-test-case.rb +0 -1171
  78. data/test/test-test-result.rb +0 -113
  79. data/test/test-test-suite-creator.rb +0 -97
  80. data/test/test-test-suite.rb +0 -150
  81. data/test/testunit-test-util.rb +0 -31
  82. data/test/ui/test_testrunmediator.rb +0 -20
  83. data/test/util/test-method-owner-finder.rb +0 -38
  84. data/test/util/test-output.rb +0 -11
  85. data/test/util/test_backtracefilter.rb +0 -41
  86. data/test/util/test_observable.rb +0 -102
  87. data/test/util/test_procwrapper.rb +0 -36
@@ -20,6 +20,7 @@ require 'test/unit/data'
20
20
  require 'test/unit/testsuite'
21
21
  require 'test/unit/test-suite-creator'
22
22
  require 'test/unit/assertion-failed-error'
23
+ require 'test/unit/auto-runner-loader'
23
24
  require 'test/unit/util/backtracefilter'
24
25
  require 'test/unit/util/output'
25
26
  require 'test/unit/util/method-owner-finder'
@@ -36,49 +37,70 @@ module Test
36
37
  # You can run two hooks before/after a TestCase run.
37
38
  #
38
39
  # Example:
39
- # class TestMyClass < Test::Unit::TestCase
40
- # class << self
41
- # def startup
40
+ #
41
+ # class TestMyClass < Test::Unit::TestCase
42
+ # class << self
43
+ # def startup
44
+ # ...
45
+ # end
46
+ #
47
+ # def shutdown
48
+ # ...
49
+ # end
50
+ # end
51
+ #
52
+ # def setup
42
53
  # ...
43
54
  # end
44
55
  #
45
- # def shutdown
56
+ # def cleanup
46
57
  # ...
47
58
  # end
48
- # end
49
59
  #
50
- # def setup
51
- # ...
52
- # end
60
+ # def teardown
61
+ # ...
62
+ # end
53
63
  #
54
- # def cleanup
55
- # ...
56
- # end
64
+ # def test_my_method1
65
+ # ...
66
+ # end
57
67
  #
58
- # def teardown
59
- # ...
68
+ # def test_my_method2
69
+ # ...
70
+ # end
60
71
  # end
61
72
  #
62
- # def test_my_method1
63
- # ...
64
- # end
73
+ # Here is a call order:
65
74
  #
66
- # def test_my_method2
67
- # ...
68
- # end
69
- # end
75
+ # 1. startup
76
+ # 1. setup
77
+ # 1. test_my_method1
78
+ # 1. cleanup
79
+ # 1. teardown
80
+ # 1. setup
81
+ # 1. test_my_method2
82
+ # 1. cleanup
83
+ # 1. teardown
84
+ # 1. shutdown
70
85
  #
71
- # Here is a call order:
72
- # * startup
73
- # * setup
74
- # * test_my_method1
75
- # * cleanup
76
- # * teardown
77
- # * setup
78
- # * test_my_method2
79
- # * cleanup
80
- # * teardown
81
- # * shutdown
86
+ # You can set an attribute to each test.
87
+ #
88
+ # Example:
89
+ #
90
+ # class TestMyClass < Test::Unit::TestCase
91
+ # attribute :speed, :fast
92
+ # def test_my_fast_method
93
+ # # You can get the attribute via `self[]`
94
+ # self[:speed] # => :fast
95
+ # ...
96
+ # end
97
+ #
98
+ # attribute :speed, :slow
99
+ # def test_my_slow_method
100
+ # self[:speed] # => :slow
101
+ # ...
102
+ # end
103
+ # end
82
104
  class TestCase
83
105
  include Attribute
84
106
  include Fixture
@@ -104,11 +126,20 @@ module Test
104
126
 
105
127
  class << self
106
128
  def inherited(sub_class) # :nodoc:
107
- require "test/unit"
108
129
  DESCENDANTS << sub_class
109
130
  super
110
131
  end
111
132
 
133
+ def include(*modules, &block) # :nodoc:
134
+ result = super
135
+ modules.each do |mod|
136
+ mod.public_instance_methods(false).each do |method_name|
137
+ AutoRunnerLoader.check(self, method_name.to_s)
138
+ end
139
+ end
140
+ result
141
+ end
142
+
112
143
  @@added_method_names = {}
113
144
  def method_added(name) # :nodoc:
114
145
  super
@@ -120,16 +151,23 @@ module Test
120
151
  source_location = find_attribute(stringified_name, :source_location)
121
152
  if source_location
122
153
  path, line = source_location
154
+ elsif respond_to?(:caller_locations, true)
155
+ location = caller_locations(1, 1)[0]
156
+ path = location.absolute_path || location.path
157
+ line = location.lineno
123
158
  else
159
+ # TODO: Remove me when Ruby 1.9 support is dropped
124
160
  path, line, = caller[0].split(/:(\d+)/, 2)
125
161
  line = line.to_i if line
126
162
  end
127
- method_locations << {
163
+ location = {
128
164
  :method_name => stringified_name,
129
165
  :path => File.expand_path(path),
130
166
  :line => line,
131
167
  }
168
+ add_method_location(location)
132
169
  added_method_names[stringified_name] = true
170
+ AutoRunnerLoader.check(self, stringified_name)
133
171
  end
134
172
 
135
173
  def added_method_names # :nodoc:
@@ -149,27 +187,29 @@ module Test
149
187
  # scope.
150
188
  #
151
189
  # Here is an example test case:
152
- # class TestMyClass < Test::Unit::TestCase
153
- # class << self
154
- # def startup
155
- # ...
190
+ #
191
+ # class TestMyClass < Test::Unit::TestCase
192
+ # class << self
193
+ # def startup
194
+ # ...
195
+ # end
156
196
  # end
157
- # end
158
197
  #
159
- # def setup
160
- # ...
161
- # end
198
+ # def setup
199
+ # ...
200
+ # end
162
201
  #
163
- # def test_my_class1
164
- # ...
165
- # end
202
+ # def test_my_class1
203
+ # ...
204
+ # end
166
205
  #
167
- # def test_my_class2
168
- # ...
206
+ # def test_my_class2
207
+ # ...
208
+ # end
169
209
  # end
170
- # end
171
210
  #
172
211
  # Here is a call order:
212
+ #
173
213
  # * startup
174
214
  # * setup
175
215
  # * test_my_class1 (or test_my_class2)
@@ -185,27 +225,29 @@ module Test
185
225
  # down fixture information used in test case scope.
186
226
  #
187
227
  # Here is an example test case:
188
- # class TestMyClass < Test::Unit::TestCase
189
- # class << self
190
- # def shutdown
191
- # ...
228
+ #
229
+ # class TestMyClass < Test::Unit::TestCase
230
+ # class << self
231
+ # def shutdown
232
+ # ...
233
+ # end
192
234
  # end
193
- # end
194
235
  #
195
- # def teardown
196
- # ...
197
- # end
236
+ # def teardown
237
+ # ...
238
+ # end
198
239
  #
199
- # def test_my_class1
200
- # ...
201
- # end
240
+ # def test_my_class1
241
+ # ...
242
+ # end
202
243
  #
203
- # def test_my_class2
204
- # ...
244
+ # def test_my_class2
245
+ # ...
246
+ # end
205
247
  # end
206
- # end
207
248
  #
208
249
  # Here is a call order:
250
+ #
209
251
  # * test_my_class1 (or test_my_class2)
210
252
  # * teardown
211
253
  # * test_my_class2 (or test_my_class1)
@@ -220,20 +262,27 @@ module Test
220
262
  @@test_orders = {}
221
263
 
222
264
  # Returns the current test order. This returns
223
- # +:alphabetic+ by default.
265
+ # `:alphabetic` by default.
224
266
  def test_order
225
- @@test_orders[self] || AVAILABLE_ORDERS.first
267
+ ancestors.each do |ancestor|
268
+ order = @@test_orders[ancestor]
269
+ return order if order
270
+ end
271
+ AVAILABLE_ORDERS.first
226
272
  end
227
273
 
228
274
  # Sets the current test order.
229
275
  #
230
276
  # Here are the available _order_:
231
- # [:alphabetic]
232
- # Default. Tests are sorted in alphabetic order.
233
- # [:random]
234
- # Tests are sorted in random order.
235
- # [:defined]
236
- # Tests are sorted in defined order.
277
+ #
278
+ # :alphabetic
279
+ # : Default. Tests are sorted in alphabetic order.
280
+ #
281
+ # :random
282
+ # : Tests are sorted in random order.
283
+ #
284
+ # :defined
285
+ # : Tests are sorted in defined order.
237
286
  def test_order=(order)
238
287
  @@test_orders[self] = order
239
288
  end
@@ -244,22 +293,22 @@ module Test
244
293
  # In declarative syntax usage, the following two
245
294
  # test definitions are the almost same:
246
295
  #
247
- # description "register user"
248
- # def test_register_user
249
- # ...
250
- # end
296
+ # description "register user"
297
+ # def test_register_user
298
+ # ...
299
+ # end
251
300
  #
252
- # test "register user" do
253
- # ...
254
- # end
301
+ # test "register user" do
302
+ # ...
303
+ # end
255
304
  #
256
305
  # In test method mark usage, the "my_test_method" is
257
306
  # treated as a test method:
258
307
  #
259
- # test
260
- # def my_test_method
261
- # assert_equal("call me", ...)
262
- # end
308
+ # test
309
+ # def my_test_method
310
+ # assert_equal("call me", ...)
311
+ # end
263
312
  def test(*test_description_or_targets, &block)
264
313
  if block_given?
265
314
  test_description = test_description_or_targets.first
@@ -281,6 +330,9 @@ module Test
281
330
  else
282
331
  targets = test_description_or_targets
283
332
  attribute(:test, true, {}, *targets)
333
+ targets.each do |target|
334
+ AutoRunnerLoader.check(self, target)
335
+ end
284
336
  end
285
337
  end
286
338
 
@@ -290,35 +342,67 @@ module Test
290
342
  # normal user" description with "test_register"
291
343
  # test.
292
344
  #
293
- # description "register a normal user"
294
- # def test_register
295
- # ...
296
- # end
345
+ # description "register a normal user"
346
+ # def test_register
347
+ # ...
348
+ # end
297
349
  def description(value, target=nil)
298
350
  targets = [target].compact
299
351
  attribute(:description, value, {}, *targets)
300
352
  end
301
353
 
354
+ # Declares that the following test uses Ractor.
355
+ #
356
+ # Tests that use Ractor are executed at the end. Because multi
357
+ # Ractor mode is enabled in the current process and it's not
358
+ # disabled even when only one Ractor is running after running
359
+ # a test that uses Ractor on Ruby 3.0. It will be solved in
360
+ # the future.
361
+ #
362
+ # This is implemented by setting the `:ractor` attribute of
363
+ # the test to `true`.
364
+ #
365
+ # @param options [Hash] See {Attribute::ClassMethods#attribute}
366
+ # for details.
367
+ #
368
+ # @return [void]
369
+ #
370
+ # @example Declares that test_do_something_with_ractor uses Ractor
371
+ #
372
+ # ractor
373
+ # def test_do_something_with_ractor
374
+ # Ractor.new do
375
+ # # ...
376
+ # end
377
+ # end
378
+ #
379
+ # @since 3.4.6
380
+ def ractor(options={})
381
+ attribute(:ractor, true, options)
382
+ end
383
+
302
384
  # Defines a sub test case.
303
385
  #
304
386
  # This is a syntax sugar. The both of the following codes are
305
387
  # the same in meaning:
306
388
  #
307
389
  # Standard:
308
- # class TestParent < Test::UnitTestCase
309
- # class TestChild < self
310
- # def test_in_child
390
+ #
391
+ # class TestParent < Test::Unit::TestCase
392
+ # class TestChild < self
393
+ # def test_in_child
394
+ # end
311
395
  # end
312
396
  # end
313
- # end
314
397
  #
315
398
  # Syntax sugar:
316
- # class TestParent < Test::UnitTestCase
317
- # sub_test_case("TestChild") do
318
- # def test_in_child
399
+ #
400
+ # class TestParent < Test::Unit::TestCase
401
+ # sub_test_case("TestChild") do
402
+ # def test_in_child
403
+ # end
319
404
  # end
320
405
  # end
321
- # end
322
406
  #
323
407
  # The difference of them are the following:
324
408
  #
@@ -335,13 +419,7 @@ module Test
335
419
  # case class context.
336
420
  # @return [Test::Unit::TestCase] Created sub test case class.
337
421
  def sub_test_case(name, &block)
338
- parent_test_case = self
339
- sub_test_case = Class.new(self) do
340
- singleton_class = class << self; self; end
341
- singleton_class.__send__(:define_method, :name) do
342
- [parent_test_case.name, name].compact.join("::")
343
- end
344
- end
422
+ sub_test_case = sub_test_case_class(name)
345
423
  sub_test_case.class_eval(&block)
346
424
  sub_test_case
347
425
  end
@@ -356,6 +434,11 @@ module Test
356
434
  # @option query [String] :method_name (nil)
357
435
  # the method name for a test.
358
436
  def test_defined?(query)
437
+ locations = find_locations(query)
438
+ not locations.empty?
439
+ end
440
+
441
+ def find_locations(query)
359
442
  query_path = query[:path]
360
443
  query_line = query[:line]
361
444
  query_method_name = query[:method_name]
@@ -368,49 +451,73 @@ module Test
368
451
  available_location = available_locations.find do |location|
369
452
  query_line >= location[:line]
370
453
  end
371
- return false if available_location.nil?
372
- return false if available_location[:test_case] != self
454
+ return [] if available_location.nil?
455
+ return [] if available_location[:test_case] != self
373
456
  available_locations = [available_location]
374
457
  end
375
458
  if query_method_name
376
459
  available_location = available_locations.find do |location|
377
- query_method_name == location[:method_name]
460
+ location[:test_case] == self and
461
+ query_method_name == location[:method_name]
378
462
  end
379
- return false if available_location.nil?
463
+ return [] if available_location.nil?
380
464
  available_locations = [available_location]
381
465
  end
382
466
 
383
- not available_locations.empty?
467
+ available_locations
384
468
  end
385
469
 
386
470
  private
387
471
  # @private
388
472
  @@method_locations = {}
473
+ # @private
474
+ @@method_location_mutex = Thread::Mutex.new
475
+
389
476
  # @private
390
477
  def method_locations
391
478
  @@method_locations[self] ||= []
392
479
  end
393
480
 
394
481
  # @private
395
- def target_method_locations(path)
396
- if path.nil?
397
- self_location = method_locations.first
398
- path = self_location[:path] if self_location
482
+ def add_method_location(location)
483
+ @@method_location_mutex.synchronize do
484
+ method_locations << location
399
485
  end
400
- return [] if path.nil?
401
-
402
- target_locations = []
403
- @@method_locations.each do |test_case, locations|
404
- locations.each do |location|
405
- absolete_path = File.expand_path(path)
406
- location_path = location[:path]
407
- location_basename = File.basename(location_path)
408
- if location_path == absolete_path or location_basename == path
409
- target_locations << location.merge(:test_case => test_case)
486
+ end
487
+
488
+ # @private
489
+ def target_method_locations(path)
490
+ @@method_location_mutex.synchronize do
491
+ if path.nil?
492
+ self_location = method_locations.first
493
+ path = self_location[:path] if self_location
494
+ end
495
+ return [] if path.nil?
496
+
497
+ target_locations = []
498
+ @@method_locations.each do |test_case, locations|
499
+ locations.each do |location|
500
+ absolete_path = File.expand_path(path)
501
+ location_path = location[:path]
502
+ location_basename = File.basename(location_path)
503
+ if location_path == absolete_path or location_basename == path
504
+ target_locations << location.merge(:test_case => test_case)
505
+ end
410
506
  end
411
507
  end
508
+ target_locations
509
+ end
510
+ end
511
+
512
+ # @private
513
+ def sub_test_case_class(name)
514
+ parent_test_case = self
515
+ Class.new(self) do
516
+ singleton_class = class << self; self; end
517
+ singleton_class.__send__(:define_method, :name) do
518
+ [parent_test_case.name, name].compact.join("::")
519
+ end
412
520
  end
413
- target_locations
414
521
  end
415
522
  end
416
523
 
@@ -432,9 +539,7 @@ module Test
432
539
  def valid? # :nodoc:
433
540
  return false unless respond_to?(@method_name)
434
541
  test_method = method(@method_name)
435
- if @internal_data.have_test_data?
436
- return false unless test_method.arity == 1
437
- else
542
+ unless @internal_data.have_test_data?
438
543
  return false unless test_method.arity <= 0
439
544
  end
440
545
  owner = Util::MethodOwnerFinder.find(self, @method_name)
@@ -453,14 +558,31 @@ module Test
453
558
  @internal_data.test_started
454
559
  yield(STARTED, name)
455
560
  yield(STARTED_OBJECT, self)
561
+ processed_exception_in_setup = false
456
562
  begin
457
- run_setup
458
- run_test
459
- run_cleanup
460
- add_pass
563
+ catch do |tag|
564
+ run_setup do
565
+ begin
566
+ run_test
567
+ run_cleanup
568
+ add_pass
569
+ rescue Exception
570
+ @internal_data.interrupted
571
+ unless handle_exception($!)
572
+ processed_exception_in_setup = true
573
+ raise
574
+ end
575
+ throw(tag)
576
+ end
577
+ end
578
+ end
461
579
  rescue Exception
462
- @internal_data.interrupted
463
- raise unless handle_exception($!)
580
+ if processed_exception_in_setup
581
+ raise
582
+ else
583
+ @internal_data.interrupted
584
+ raise unless handle_exception($!)
585
+ end
464
586
  ensure
465
587
  begin
466
588
  run_teardown
@@ -482,35 +604,37 @@ module Test
482
604
  #
483
605
  # You can add additional setup tasks by the following
484
606
  # code:
485
- # class TestMyClass < Test::Unit::TestCase
486
- # def setup
487
- # ...
488
- # end
489
607
  #
490
- # setup
491
- # def my_setup1
492
- # ...
493
- # end
608
+ # class TestMyClass < Test::Unit::TestCase
609
+ # def setup
610
+ # ...
611
+ # end
494
612
  #
495
- # setup do
496
- # ... # setup callback1
497
- # end
613
+ # setup
614
+ # def my_setup1
615
+ # ...
616
+ # end
498
617
  #
499
- # setup
500
- # def my_setup2
501
- # ...
502
- # end
618
+ # setup do
619
+ # ... # setup callback1
620
+ # end
503
621
  #
504
- # setup do
505
- # ... # setup callback2
506
- # end
622
+ # setup
623
+ # def my_setup2
624
+ # ...
625
+ # end
626
+ #
627
+ # setup do
628
+ # ... # setup callback2
629
+ # end
507
630
  #
508
- # def test_my_class
509
- # ...
631
+ # def test_my_class
632
+ # ...
633
+ # end
510
634
  # end
511
- # end
512
635
  #
513
636
  # Here is a call order:
637
+ #
514
638
  # * setup
515
639
  # * my_setup1
516
640
  # * setup callback1
@@ -527,35 +651,37 @@ module Test
527
651
  #
528
652
  # You can add additional cleanup tasks by the following
529
653
  # code:
530
- # class TestMyClass < Test::Unit::TestCase
531
- # def cleanup
532
- # ...
533
- # end
534
654
  #
535
- # cleanup
536
- # def my_cleanup1
537
- # ...
538
- # end
655
+ # class TestMyClass < Test::Unit::TestCase
656
+ # def cleanup
657
+ # ...
658
+ # end
539
659
  #
540
- # cleanup do
541
- # ... # cleanup callback1
542
- # end
660
+ # cleanup
661
+ # def my_cleanup1
662
+ # ...
663
+ # end
543
664
  #
544
- # cleanup
545
- # def my_cleanup2
546
- # ...
547
- # end
665
+ # cleanup do
666
+ # ... # cleanup callback1
667
+ # end
548
668
  #
549
- # cleanup do
550
- # ... # cleanup callback2
551
- # end
669
+ # cleanup
670
+ # def my_cleanup2
671
+ # ...
672
+ # end
673
+ #
674
+ # cleanup do
675
+ # ... # cleanup callback2
676
+ # end
552
677
  #
553
- # def test_my_class
554
- # ...
678
+ # def test_my_class
679
+ # ...
680
+ # end
555
681
  # end
556
- # end
557
682
  #
558
683
  # Here is a call order:
684
+ #
559
685
  # * test_my_class
560
686
  # * cleanup callback2
561
687
  # * my_cleanup2
@@ -570,35 +696,37 @@ module Test
570
696
  #
571
697
  # You can add additional teardown tasks by the following
572
698
  # code:
573
- # class TestMyClass < Test::Unit::TestCase
574
- # def teardown
575
- # ...
576
- # end
577
699
  #
578
- # teardown
579
- # def my_teardown1
580
- # ...
581
- # end
700
+ # class TestMyClass < Test::Unit::TestCase
701
+ # def teardown
702
+ # ...
703
+ # end
582
704
  #
583
- # teardown do
584
- # ... # teardown callback1
585
- # end
705
+ # teardown
706
+ # def my_teardown1
707
+ # ...
708
+ # end
586
709
  #
587
- # teardown
588
- # def my_teardown2
589
- # ...
590
- # end
710
+ # teardown do
711
+ # ... # teardown callback1
712
+ # end
591
713
  #
592
- # teardown do
593
- # ... # teardown callback2
594
- # end
714
+ # teardown
715
+ # def my_teardown2
716
+ # ...
717
+ # end
718
+ #
719
+ # teardown do
720
+ # ... # teardown callback2
721
+ # end
595
722
  #
596
- # def test_my_class
597
- # ...
723
+ # def test_my_class
724
+ # ...
725
+ # end
598
726
  # end
599
- # end
600
727
  #
601
728
  # Here is a call order:
729
+ #
602
730
  # * test_my_class
603
731
  # * teardown callback2
604
732
  # * my_teardown2
@@ -618,18 +746,33 @@ module Test
618
746
 
619
747
  # Returns a label of test data for the test. If the
620
748
  # test isn't associated with any test data, it returns
621
- # +nil+.
749
+ # `nil`.
622
750
  def data_label
623
751
  @internal_data.test_data_label
624
752
  end
625
753
 
754
+ # Returns test data for the test. If the test isn't associated
755
+ # with any test data, it returns `nil`.
756
+ def data
757
+ @internal_data.test_data
758
+ end
759
+
626
760
  # Returns a human-readable name for the specific test that
627
761
  # this instance of TestCase represents.
628
762
  def name
763
+ "#{local_name}(#{self.class.name})"
764
+ end
765
+
766
+ # Returns a human-readable name for the specific test that this
767
+ # instance of TestCase represents.
768
+ #
769
+ # `#local_name` doesn't include class name. `#name` includes
770
+ # class name.
771
+ def local_name
629
772
  if @internal_data.have_test_data?
630
- "#{@method_name}[#{data_label}](#{self.class.name})"
773
+ "#{@method_name}[#{data_label}]"
631
774
  else
632
- "#{@method_name}(#{self.class.name})"
775
+ @method_name.to_s
633
776
  end
634
777
  end
635
778
 
@@ -707,13 +850,23 @@ module Test
707
850
  end
708
851
 
709
852
  def run_test
853
+ signature = "#{self.class}\##{@method_name}"
710
854
  redefined_info = self[:redefined]
711
855
  if redefined_info
712
- notify("#{self.class}\##{@method_name} was redefined",
856
+ notify("<#{signature}> was redefined",
713
857
  :backtrace => redefined_info[:backtrace])
714
858
  end
859
+ if self[:ractor] and not defined?(::Ractor)
860
+ omit("<#{signature}> requires Ractor")
861
+ end
715
862
  if @internal_data.have_test_data?
716
- __send__(@method_name, @internal_data.test_data)
863
+ test_method = method(@method_name)
864
+ arity = test_method.arity
865
+ if arity.zero?
866
+ __send__(@method_name)
867
+ else
868
+ __send__(@method_name, @internal_data.test_data)
869
+ end
717
870
  else
718
871
  __send__(@method_name)
719
872
  end