minitest 5.15.0 → 5.16.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,7 +51,7 @@ class TestMinitestMock < Minitest::Test
51
51
  @mock.sum
52
52
  end
53
53
 
54
- assert_equal "mocked method :sum expects 2 arguments, got 0", e.message
54
+ assert_equal "mocked method :sum expects 2 arguments, got []", e.message
55
55
  end
56
56
 
57
57
  def test_return_mock_does_not_raise
@@ -210,7 +210,7 @@ class TestMinitestMock < Minitest::Test
210
210
  mock.a
211
211
  end
212
212
 
213
- assert_equal "No more expects available for :a: []", e.message
213
+ assert_equal "No more expects available for :a: [] {}", e.message
214
214
  end
215
215
 
216
216
  def test_same_method_expects_are_verified_when_all_called
@@ -252,6 +252,21 @@ class TestMinitestMock < Minitest::Test
252
252
  assert_equal exp, e.message
253
253
  end
254
254
 
255
+ def test_handles_kwargs_in_error_message
256
+ mock = Minitest::Mock.new
257
+
258
+ mock.expect :foo, nil, [], kw: true
259
+ mock.expect :foo, nil, [], kw: false
260
+
261
+ mock.foo kw: true
262
+
263
+ e = assert_raises(MockExpectationError) { mock.verify }
264
+
265
+ exp = "expected foo(:kw=>false) => nil, got [foo(:kw=>true) => nil]"
266
+
267
+ assert_equal exp, e.message
268
+ end
269
+
255
270
  def test_verify_passes_when_mock_block_returns_true
256
271
  mock = Minitest::Mock.new
257
272
  mock.expect :foo, nil do
@@ -270,11 +285,180 @@ class TestMinitestMock < Minitest::Test
270
285
  a1 == arg1 && a2 == arg2 && a3 == arg3
271
286
  end
272
287
 
273
- mock.foo arg1, arg2, arg3
288
+ assert_silent do
289
+ if RUBY_VERSION > "3" then
290
+ mock.foo arg1, arg2, arg3
291
+ else
292
+ mock.foo arg1, arg2, **arg3 # oddity just for ruby 2.7
293
+ end
294
+ end
295
+
296
+ assert_mock mock
297
+ end
298
+
299
+ def test_mock_block_is_passed_keyword_args__block
300
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
301
+ mock = Minitest::Mock.new
302
+ mock.expect :foo, nil do |k1:, k2:, k3:|
303
+ k1 == arg1 && k2 == arg2 && k3 == arg3
304
+ end
305
+
306
+ mock.foo(k1: arg1, k2: arg2, k3: arg3)
274
307
 
275
308
  assert_mock mock
276
309
  end
277
310
 
311
+ def test_mock_block_is_passed_keyword_args__block_bad_missing
312
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
313
+ mock = Minitest::Mock.new
314
+ mock.expect :foo, nil do |k1:, k2:, k3:|
315
+ k1 == arg1 && k2 == arg2 && k3 == arg3
316
+ end
317
+
318
+ e = assert_raises ArgumentError do
319
+ mock.foo(k1: arg1, k2: arg2)
320
+ end
321
+
322
+ # basically testing ruby ... need ? for ruby < 2.7 :(
323
+ assert_match(/missing keyword: :?k3/, e.message)
324
+ end
325
+
326
+ def test_mock_block_is_passed_keyword_args__block_bad_extra
327
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
328
+ mock = Minitest::Mock.new
329
+ mock.expect :foo, nil do |k1:, k2:|
330
+ k1 == arg1 && k2 == arg2 && k3 == arg3
331
+ end
332
+
333
+ e = assert_raises ArgumentError do
334
+ mock.foo(k1: arg1, k2: arg2, k3: arg3)
335
+ end
336
+
337
+ # basically testing ruby ... need ? for ruby < 2.7 :(
338
+ assert_match(/unknown keyword: :?k3/, e.message)
339
+ end
340
+
341
+ def test_mock_block_is_passed_keyword_args__block_bad_value
342
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
343
+ mock = Minitest::Mock.new
344
+ mock.expect :foo, nil do |k1:, k2:, k3:|
345
+ k1 == arg1 && k2 == arg2 && k3 == arg3
346
+ end
347
+
348
+ e = assert_raises MockExpectationError do
349
+ mock.foo(k1: arg1, k2: arg2, k3: :BAD!)
350
+ end
351
+
352
+ exp = "mocked method :foo failed block w/ [] {:k1=>:bar, :k2=>[1, 2, 3], :k3=>:BAD!}"
353
+ assert_equal exp, e.message
354
+ end
355
+
356
+ def test_mock_block_is_passed_keyword_args__args
357
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
358
+ mock = Minitest::Mock.new
359
+ mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
360
+
361
+ mock.foo(k1: arg1, k2: arg2, k3: arg3)
362
+
363
+ assert_mock mock
364
+ end
365
+
366
+ def with_kwargs_env
367
+ ENV["MT_KWARGS_HAC\K"] = "1"
368
+
369
+ yield
370
+ ensure
371
+ ENV.delete "MT_KWARGS_HAC\K"
372
+ end
373
+
374
+ def test_mock_block_is_passed_keyword_args__args__old_style_bad
375
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
376
+ mock = Minitest::Mock.new
377
+ mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
378
+
379
+ e = assert_raises ArgumentError do
380
+ mock.foo(k1: arg1, k2: arg2, k3: arg3)
381
+ end
382
+
383
+ assert_equal "mocked method :foo expects 1 arguments, got []", e.message
384
+ end
385
+
386
+ def test_mock_block_is_passed_keyword_args__args__old_style_env
387
+ with_kwargs_env do
388
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
389
+ mock = Minitest::Mock.new
390
+ mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
391
+
392
+ mock.foo(k1: arg1, k2: arg2, k3: arg3)
393
+
394
+ assert_mock mock
395
+ end
396
+ end
397
+
398
+ def test_mock_block_is_passed_keyword_args__args__old_style_both
399
+ with_kwargs_env do
400
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
401
+ mock = Minitest::Mock.new
402
+
403
+ assert_output nil, /Using MT_KWARGS_HAC. yet passing kwargs/ do
404
+ mock.expect :foo, nil, [{}], k1: arg1, k2: arg2, k3: arg3
405
+ end
406
+
407
+ mock.foo({}, k1: arg1, k2: arg2, k3: arg3)
408
+
409
+ assert_mock mock
410
+ end
411
+ end
412
+
413
+ def test_mock_block_is_passed_keyword_args__args_bad_missing
414
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
415
+ mock = Minitest::Mock.new
416
+ mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
417
+
418
+ e = assert_raises ArgumentError do
419
+ mock.foo(k1: arg1, k2: arg2)
420
+ end
421
+
422
+ assert_equal "mocked method :foo expects 3 keyword arguments, got %p" % {k1: arg1, k2: arg2}, e.message
423
+ end
424
+
425
+ def test_mock_block_is_passed_keyword_args__args_bad_extra
426
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
427
+ mock = Minitest::Mock.new
428
+ mock.expect :foo, nil, k1: arg1, k2: arg2
429
+
430
+ e = assert_raises ArgumentError do
431
+ mock.foo(k1: arg1, k2: arg2, k3: arg3)
432
+ end
433
+
434
+ assert_equal "mocked method :foo expects 2 keyword arguments, got %p" % {k1: arg1, k2: arg2, k3: arg3}, e.message
435
+ end
436
+
437
+ def test_mock_block_is_passed_keyword_args__args_bad_key
438
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
439
+ mock = Minitest::Mock.new
440
+ mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
441
+
442
+ e = assert_raises MockExpectationError do
443
+ mock.foo(k1: arg1, k2: arg2, BAD: arg3)
444
+ end
445
+
446
+ assert_includes e.message, "unexpected keywords [:k1, :k2, :k3]"
447
+ assert_includes e.message, "vs [:k1, :k2, :BAD]"
448
+ end
449
+
450
+ def test_mock_block_is_passed_keyword_args__args_bad_val
451
+ arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
452
+ mock = Minitest::Mock.new
453
+ mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
454
+
455
+ e = assert_raises MockExpectationError do
456
+ mock.foo(k1: arg1, k2: :BAD!, k3: arg3)
457
+ end
458
+
459
+ assert_match(/unexpected keyword arguments.* vs .*:k2=>:BAD!/, e.message)
460
+ end
461
+
278
462
  def test_mock_block_is_passed_function_block
279
463
  mock = Minitest::Mock.new
280
464
  block = proc { "bar" }
@@ -286,6 +470,13 @@ class TestMinitestMock < Minitest::Test
286
470
  assert_mock mock
287
471
  end
288
472
 
473
+ def test_mock_forward_keyword_arguments
474
+ mock = Minitest::Mock.new
475
+ mock.expect(:foo, nil) { |bar:| bar == 'bar' }
476
+ mock.foo(bar: 'bar')
477
+ assert_mock mock
478
+ end
479
+
289
480
  def test_verify_fails_when_mock_block_returns_false
290
481
  mock = Minitest::Mock.new
291
482
  mock.expect :foo, nil do
@@ -293,12 +484,12 @@ class TestMinitestMock < Minitest::Test
293
484
  end
294
485
 
295
486
  e = assert_raises(MockExpectationError) { mock.foo }
296
- exp = "mocked method :foo failed block w/ []"
487
+ exp = "mocked method :foo failed block w/ [] {}"
297
488
 
298
489
  assert_equal exp, e.message
299
490
  end
300
491
 
301
- def test_mock_block_throws_if_args_passed
492
+ def test_mock_block_raises_if_args_passed
302
493
  mock = Minitest::Mock.new
303
494
 
304
495
  e = assert_raises(ArgumentError) do
@@ -312,6 +503,20 @@ class TestMinitestMock < Minitest::Test
312
503
  assert_match exp, e.message
313
504
  end
314
505
 
506
+ def test_mock_block_raises_if_kwargs_passed
507
+ mock = Minitest::Mock.new
508
+
509
+ e = assert_raises(ArgumentError) do
510
+ mock.expect :foo, nil, kwargs:1 do
511
+ true
512
+ end
513
+ end
514
+
515
+ exp = "kwargs ignored when block given"
516
+
517
+ assert_match exp, e.message
518
+ end
519
+
315
520
  def test_mock_returns_retval_when_called_with_block
316
521
  mock = Minitest::Mock.new
317
522
  mock.expect(:foo, 32) do
@@ -519,6 +724,19 @@ class TestMinitestStub < Minitest::Test
519
724
  @tc.assert_equal true, rs
520
725
  end
521
726
 
727
+ def test_mock_with_yield_kwargs
728
+ mock = Minitest::Mock.new
729
+ rs = nil
730
+
731
+ File.stub :open, true, mock, kw:42 do
732
+ File.open "foo.txt", "r" do |f, kw:|
733
+ rs = kw
734
+ end
735
+ end
736
+
737
+ @tc.assert_equal 42, rs
738
+ end
739
+
522
740
  alias test_stub_value__old test_stub_value # TODO: remove/rename
523
741
 
524
742
  ## Permutation Sets:
@@ -30,6 +30,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
30
30
  end
31
31
 
32
32
  def setup
33
+ super
33
34
  self.io = StringIO.new("")
34
35
  self.r = new_composite_reporter
35
36
  end
@@ -505,7 +505,7 @@ describe Minitest::Spec do
505
505
  it "needs to verify regexp matches" do
506
506
  @assertion_count += 3 # must_match is 2 assertions
507
507
 
508
- assert_success _("blah").must_match(/\w+/)
508
+ assert_kind_of MatchData, _("blah").must_match(/\w+/)
509
509
 
510
510
  assert_triggered "Expected /\\d+/ to match \"blah\"." do
511
511
  _("blah").must_match(/\d+/)
@@ -744,6 +744,10 @@ describe Minitest::Spec, :subject do
744
744
  end
745
745
 
746
746
  class TestMetaStatic < Minitest::Test
747
+ def assert_method_count expected, klass
748
+ assert_equal expected, klass.public_instance_methods.grep(/^test_/).count
749
+ end
750
+
747
751
  def test_children
748
752
  Minitest::Spec.children.clear # prevents parallel run
749
753
 
@@ -777,8 +781,8 @@ class TestMetaStatic < Minitest::Test
777
781
  end
778
782
  end
779
783
 
780
- assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
781
- assert_equal 1, inner.public_instance_methods.grep(/^test_/).count
784
+ assert_method_count 1, outer
785
+ assert_method_count 1, inner
782
786
  end
783
787
 
784
788
  def test_it_wont_add_test_methods_to_children
@@ -792,14 +796,18 @@ class TestMetaStatic < Minitest::Test
792
796
  end
793
797
  end
794
798
 
795
- assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
796
- assert_equal 0, inner.public_instance_methods.grep(/^test_/).count
799
+ assert_method_count 1, outer
800
+ assert_method_count 0, inner
797
801
  end
798
802
  end
799
803
 
800
804
  class TestMeta < MetaMetaMetaTestCase
801
805
  # do not call parallelize_me! here because specs use register_spec_type globally
802
806
 
807
+ def assert_defined_methods expected, klass
808
+ assert_equal expected, klass.instance_methods(false).sort.map(&:to_s)
809
+ end
810
+
803
811
  def util_structure
804
812
  y = z = nil
805
813
  before_list = []
@@ -872,7 +880,7 @@ class TestMeta < MetaMetaMetaTestCase
872
880
  end
873
881
  end
874
882
 
875
- test_name = spec_class.instance_methods.sort.grep(/test/).first
883
+ test_name = spec_class.instance_methods.sort.grep(/test_/).first
876
884
 
877
885
  spec = spec_class.new test_name
878
886
 
@@ -921,9 +929,9 @@ class TestMeta < MetaMetaMetaTestCase
921
929
  inner_methods2 = inner_methods1 +
922
930
  %w[test_0002_anonymous test_0003_anonymous]
923
931
 
924
- assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
925
- assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
926
- assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
932
+ assert_defined_methods top_methods, x
933
+ assert_defined_methods inner_methods1, y
934
+ assert_defined_methods inner_methods2, z
927
935
  end
928
936
 
929
937
  def test_structure_postfix_it
@@ -940,8 +948,8 @@ class TestMeta < MetaMetaMetaTestCase
940
948
  it "inner-it" do end
941
949
  end
942
950
 
943
- assert_equal %w[test_0001_inner-it], y.instance_methods(false).map(&:to_s)
944
- assert_equal %w[test_0001_inner-it], z.instance_methods(false).map(&:to_s)
951
+ assert_defined_methods %w[test_0001_inner-it], y
952
+ assert_defined_methods %w[test_0001_inner-it], z
945
953
  end
946
954
 
947
955
  def test_setup_teardown_behavior
@@ -972,9 +980,9 @@ class TestMeta < MetaMetaMetaTestCase
972
980
  ].sort
973
981
 
974
982
  assert_equal test_methods, [x1, x2]
975
- assert_equal test_methods, x.instance_methods.grep(/^test/).map(&:to_s).sort
976
- assert_equal [], y.instance_methods.grep(/^test/)
977
- assert_equal [], z.instance_methods.grep(/^test/)
983
+ assert_defined_methods test_methods, x
984
+ assert_defined_methods [], y
985
+ assert_defined_methods [], z
978
986
  end
979
987
 
980
988
  def test_structure_subclasses
@@ -48,9 +48,11 @@ class TestMinitestUnit < MetaMetaMetaTestCase
48
48
  "test/test_autotest.rb:62:in `test_add_exception'"]
49
49
  ex = util_expand_bt ex
50
50
 
51
- fu = Minitest.filter_backtrace(bt)
51
+ Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
52
+ fu = Minitest.filter_backtrace(bt)
52
53
 
53
- assert_equal ex, fu
54
+ assert_equal ex, fu
55
+ end
54
56
  end
55
57
 
56
58
  def test_filter_backtrace_all_unit
@@ -71,8 +73,10 @@ class TestMinitestUnit < MetaMetaMetaTestCase
71
73
  bt = util_expand_bt bt
72
74
 
73
75
  ex = ["-e:1"]
74
- fu = Minitest.filter_backtrace bt
75
- assert_equal ex, fu
76
+ Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
77
+ fu = Minitest.filter_backtrace bt
78
+ assert_equal ex, fu
79
+ end
76
80
  end
77
81
 
78
82
  def test_filter_backtrace__empty
@@ -95,24 +99,26 @@ class TestMinitestUnit < MetaMetaMetaTestCase
95
99
  end
96
100
 
97
101
  expected = clean <<-EOM
98
- EF
102
+ FE
99
103
 
100
104
  Finished in 0.00
101
105
 
102
- 1) Error:
103
- FakeNamedTestXX#test_this_is_non_ascii_failure_message:
104
- RuntimeError: ЁЁЁ
105
- FILE:LINE:in `test_this_is_non_ascii_failure_message'
106
-
107
- 2) Failure:
106
+ 1) Failure:
108
107
  FakeNamedTestXX#test_this_is_not_ascii_assertion [FILE:LINE]:
109
108
  Expected: \"ЁЁЁ\"
110
109
  Actual: \"ёёё\"
111
110
 
111
+ 2) Error:
112
+ FakeNamedTestXX#test_this_is_non_ascii_failure_message:
113
+ RuntimeError: ЁЁЁ
114
+ FILE:LINE:in `test_this_is_non_ascii_failure_message'
115
+
112
116
  2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
113
117
  EOM
114
118
 
115
- assert_report expected
119
+ Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
120
+ assert_report expected
121
+ end
116
122
  end
117
123
 
118
124
  def test_passed_eh_teardown_good
@@ -158,11 +164,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
158
164
  end
159
165
 
160
166
  def util_expand_bt bt
161
- if RUBY_VERSION >= "1.9.0" then
162
- bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
163
- else
164
- bt
165
- end
167
+ bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
166
168
  end
167
169
  end
168
170
 
@@ -254,7 +256,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
254
256
  end
255
257
 
256
258
  expected = clean <<-EOM
257
- E.
259
+ .E
258
260
 
259
261
  Finished in 0.00
260
262
 
@@ -301,7 +303,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
301
303
  setup_basic_tu
302
304
 
303
305
  expected = clean <<-EOM
304
- F.
306
+ .F
305
307
 
306
308
  Finished in 0.00
307
309
 
@@ -328,6 +330,10 @@ class TestMinitestRunner < MetaMetaMetaTestCase
328
330
  end
329
331
  end
330
332
 
333
+ def test_seed # this is set for THIS run, so I'm not testing it's actual value
334
+ assert_instance_of Integer, Minitest.seed
335
+ end
336
+
331
337
  def test_run_failing_filtered
332
338
  setup_basic_tu
333
339
 
@@ -485,7 +491,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
485
491
  end
486
492
 
487
493
  expected = clean <<-EOM
488
- S.
494
+ .S
489
495
 
490
496
  Finished in 0.00
491
497
 
@@ -512,8 +518,8 @@ class TestMinitestRunner < MetaMetaMetaTestCase
512
518
  end
513
519
 
514
520
  expected = clean <<-EOM
515
- FakeNamedTestXX#test_skip = 0.00 s = S
516
521
  FakeNamedTestXX#test_something = 0.00 s = .
522
+ FakeNamedTestXX#test_skip = 0.00 s = S
517
523
 
518
524
  Finished in 0.00
519
525
 
@@ -527,6 +533,33 @@ class TestMinitestRunner < MetaMetaMetaTestCase
527
533
  assert_report expected, %w[--seed 42 --verbose]
528
534
  end
529
535
 
536
+ def test_run_skip_show_skips
537
+ @tu =
538
+ Class.new FakeNamedTest do
539
+ def test_something
540
+ assert true
541
+ end
542
+
543
+ def test_skip
544
+ skip "not yet"
545
+ end
546
+ end
547
+
548
+ expected = clean <<-EOM
549
+ .S
550
+
551
+ Finished in 0.00
552
+
553
+ 1) Skipped:
554
+ FakeNamedTestXX#test_skip [FILE:LINE]:
555
+ not yet
556
+
557
+ 2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
558
+ EOM
559
+
560
+ assert_report expected, %w[--seed 42 --show-skips]
561
+ end
562
+
530
563
  def test_run_with_other_runner
531
564
  @tu =
532
565
  Class.new FakeNamedTest do
@@ -627,6 +660,8 @@ class TestMinitestRunner < MetaMetaMetaTestCase
627
660
  2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
628
661
  EOM
629
662
 
663
+ skip if Minitest.parallel_executor.size < 2 # locks up test runner if 1 CPU
664
+
630
665
  assert_report(expected) do |reporter|
631
666
  reporter.extend(Module.new {
632
667
  define_method("record") do |result|
@@ -805,13 +840,51 @@ class TestMinitestRunnable < Minitest::Test
805
840
  end
806
841
 
807
842
  def test_spec_marshal_with_exception
808
- klass = describe("whatever") { it("passes") { raise Class.new(StandardError)} }
843
+ klass = describe("whatever") {
844
+ it("raises, badly") {
845
+ raise Class.new(StandardError), "this is bad!"
846
+ }
847
+ }
848
+
809
849
  rm = klass.runnable_methods.first
810
850
 
811
851
  # Run the test
812
852
  @tc = klass.new(rm).run
813
853
 
814
854
  assert_kind_of Minitest::Result, @tc
855
+ assert_instance_of Minitest::UnexpectedError, @tc.failure
856
+
857
+ msg = @tc.failure.error.message
858
+ assert_includes msg, "Neutered Exception #<Class:"
859
+ assert_includes msg, "this is bad!"
860
+
861
+ # Pass it over the wire
862
+ over_the_wire = Marshal.load Marshal.dump @tc
863
+
864
+ assert_equal @tc.time, over_the_wire.time
865
+ assert_equal @tc.name, over_the_wire.name
866
+ assert_equal @tc.assertions, over_the_wire.assertions
867
+ assert_equal @tc.failures, over_the_wire.failures
868
+ assert_equal @tc.klass, over_the_wire.klass
869
+ end
870
+
871
+ def test_spec_marshal_with_exception_nameerror
872
+ klass = describe("whatever") {
873
+ it("raises nameerror") {
874
+ NOPE::does_not_exist
875
+ }
876
+ }
877
+
878
+ rm = klass.runnable_methods.first
879
+
880
+ # Run the test
881
+ @tc = klass.new(rm).run
882
+
883
+ assert_kind_of Minitest::Result, @tc
884
+ assert_instance_of Minitest::UnexpectedError, @tc.failure
885
+
886
+ msg = @tc.failure.error.message
887
+ assert_includes msg, "uninitialized constant TestMinitestRunnable::NOPE"
815
888
 
816
889
  # Pass it over the wire
817
890
  over_the_wire = Marshal.load Marshal.dump @tc
@@ -885,7 +958,7 @@ class TestMinitestUnitTestCase < Minitest::Test
885
958
  random_tests_3 = sample_test_case 1_000
886
959
 
887
960
  assert_equal random_tests_1, random_tests_2
888
- refute_equal random_tests_1, random_tests_3
961
+ assert_equal random_tests_1, random_tests_3
889
962
  end
890
963
 
891
964
  def test_runnable_methods_sorted
@@ -0,0 +1,46 @@
1
+ require "minitest/autorun"
2
+ require "hoe"
3
+
4
+ require "minitest/test_task"
5
+
6
+ Hoe.load_plugins # make sure Hoe::Test is loaded
7
+
8
+ class TestHoeTest < Minitest::Test
9
+ PATH = "test/minitest/test_minitest_test_task.rb"
10
+
11
+ mt_path = %w[lib test .].join File::PATH_SEPARATOR
12
+
13
+ MT_EXPECTED = %W[-I#{mt_path} -w
14
+ -e '%srequire "#{PATH}"'
15
+ --].join(" ") + " "
16
+
17
+ def test_make_test_cmd_for_minitest
18
+ skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
19
+
20
+ require "minitest/test_task"
21
+
22
+ framework = %(require "minitest/autorun"; )
23
+
24
+ @tester = Minitest::TestTask.create :test do |t|
25
+ t.test_globs = [PATH]
26
+ end
27
+
28
+ assert_equal MT_EXPECTED % [framework].join("; "), @tester.make_test_cmd
29
+ end
30
+
31
+ def test_make_test_cmd_for_minitest_prelude
32
+ skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
33
+
34
+ require "minitest/test_task"
35
+
36
+ prelude = %(require "other/file")
37
+ framework = %(require "minitest/autorun"; )
38
+
39
+ @tester = Minitest::TestTask.create :test do |t|
40
+ t.test_prelude = prelude
41
+ t.test_globs = [PATH]
42
+ end
43
+
44
+ assert_equal MT_EXPECTED % [prelude, framework].join("; "), @tester.make_test_cmd
45
+ end
46
+ end
data.tar.gz.sig CHANGED
Binary file