Class: TestMinitestRunner
- Inherits:
-
MetaMetaMetaTestCase
show all
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb
Defined Under Namespace
Classes: Latch
Constant Summary
Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS
Minitest::Assertions::E, Minitest::Assertions::UNDEFINED
Minitest::Runnable::SIGNALS
Instance Attribute Summary
#output, #reporter, #tu
#assertions, #failures, #time
Instance Method Summary
collapse
#assert_report, #first_reporter, #normalize_output, #restore_env, #run_tu_with_fresh_reporter, #setup, #with_stderr
#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler
#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?
#after_setup, #after_teardown, #before_setup, #before_teardown, #setup, #teardown
#class_name, #error?, #location, #passed?, #result_code, #skipped?
#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #fail_after, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff
#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler
Instance Method Details
#assert_filtering(filter, name, expected, a = false) ⇒ Object
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 351
def assert_filtering filter, name, expected, a = false
args = %W[--#{filter} #{name} --seed 42]
alpha = Class.new FakeNamedTest do
define_method :test_something do
assert a
end
end
Object.const_set(:Alpha, alpha)
beta = Class.new FakeNamedTest do
define_method :test_something do
assert true
end
end
Object.const_set(:Beta, beta)
@tus = [alpha, beta]
assert_report expected, args
ensure
Object.send :remove_const, :Alpha
Object.send :remove_const, :Beta
end
|
#setup_basic_tu ⇒ Object
320
321
322
323
324
325
326
327
328
329
330
331
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 320
def setup_basic_tu
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_failure
assert false
end
end
end
|
#test_class_runnables ⇒ Object
do not parallelize this suite… it just can’t handle it.
208
209
210
211
212
213
214
215
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 208
def test_class_runnables
@assertion_count = 0
tc = Class.new(Minitest::Test)
assert_equal 1, Minitest::Test.runnables.size
assert_equal [tc], Minitest::Test.runnables
end
|
#test_run_error ⇒ Object
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 246
def test_run_error
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_error
raise "unhandled exception"
end
end
expected = clean <<-EOM
.E
Finished in 0.00
1) Error:
FakeNamedTestXX#test_error:
RuntimeError: unhandled exception
FILE:LINE:in \`test_error\'
2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
EOM
assert_report expected
end
|
#test_run_error_teardown ⇒ Object
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 274
def test_run_error_teardown
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def teardown
raise "unhandled exception"
end
end
expected = clean <<-EOM
E
Finished in 0.00
1) Error:
FakeNamedTestXX#test_something:
RuntimeError: unhandled exception
FILE:LINE:in \`teardown\'
1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
EOM
assert_report expected
end
|
#test_run_failing ⇒ Object
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 302
def test_run_failing
setup_basic_tu
expected = clean <<-EOM
.F
Finished in 0.00
1) Failure:
FakeNamedTestXX#test_failure [FILE:LINE]:
Expected false to be truthy.
2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
EOM
assert_report expected
end
|
#test_run_failing_excluded ⇒ Object
412
413
414
415
416
417
418
419
420
421
422
423
424
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 412
def test_run_failing_excluded
setup_basic_tu
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected, %w[--exclude /failure/ --seed 42]
end
|
#test_run_failing_filtered ⇒ Object
337
338
339
340
341
342
343
344
345
346
347
348
349
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 337
def test_run_failing_filtered
setup_basic_tu
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected, %w[--name /some|thing/ --seed 42]
end
|
#test_run_filtered_excluding_string_method_only ⇒ Object
450
451
452
453
454
455
456
457
458
459
460
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 450
def test_run_filtered_excluding_string_method_only
expected = clean <<-EOM
Finished in 0.00
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "exclude", "test_something", expected, :pass
end
|
#test_run_filtered_excluding_suite_name ⇒ Object
426
427
428
429
430
431
432
433
434
435
436
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 426
def test_run_filtered_excluding_suite_name
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "exclude", "/Alpha#test_something/", expected
end
|
#test_run_filtered_excluding_suite_name_string ⇒ Object
438
439
440
441
442
443
444
445
446
447
448
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 438
def test_run_filtered_excluding_suite_name_string
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "exclude", "Alpha#test_something", expected
end
|
#test_run_filtered_including_suite_name ⇒ Object
376
377
378
379
380
381
382
383
384
385
386
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 376
def test_run_filtered_including_suite_name
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "name", "/Beta#test_something/", expected
end
|
#test_run_filtered_including_suite_name_string ⇒ Object
388
389
390
391
392
393
394
395
396
397
398
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 388
def test_run_filtered_including_suite_name_string
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "name", "Beta#test_something", expected
end
|
#test_run_filtered_string_method_only ⇒ Object
400
401
402
403
404
405
406
407
408
409
410
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 400
def test_run_filtered_string_method_only
expected = clean <<-EOM
..
Finished in 0.00
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "name", "test_something", expected, :pass
end
|
#test_run_parallel ⇒ Object
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 621
def test_run_parallel
test_count = 2
test_latch = Latch.new test_count
wait_latch = Latch.new test_count
main_latch = Latch.new
thread = Thread.new {
Thread.current.abort_on_exception = true
test_latch.await
main_latch.release
}
@tu =
Class.new FakeNamedTest do
parallelize_me!
test_count.times do |i|
define_method :"test_wait_on_main_thread_#{i}" do
test_latch.release
main_latch.await
assert true
end
end
end
expected = clean <<-EOM
..
Finished in 0.00
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
skip if Minitest.parallel_executor.size < 2
assert_report(expected) do |reporter|
reporter.extend(Module.new {
define_method("record") do |result|
super(result)
wait_latch.release
end
define_method("report") do
wait_latch.await
super()
end
})
end
assert thread.join
end
|
#test_run_passing ⇒ Object
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 462
def test_run_passing
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
end
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected
end
|
#test_run_skip ⇒ Object
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 481
def test_run_skip
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_skip
skip "not yet"
end
end
expected = clean <<-EOM
.S
Finished in 0.00
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
You have skipped tests. Run with --verbose for details.
EOM
restore_env do
assert_report expected
end
end
|
#test_run_skip_show_skips ⇒ Object
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 536
def test_run_skip_show_skips
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_skip
skip "not yet"
end
end
expected = clean <<-EOM
.S
Finished in 0.00
1) Skipped:
FakeNamedTestXX#test_skip [FILE:LINE]:
not yet
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
EOM
assert_report expected, %w[--seed 42 --show-skips]
end
|
#test_run_skip_verbose ⇒ Object
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 508
def test_run_skip_verbose
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_skip
skip "not yet"
end
end
expected = clean <<-EOM
FakeNamedTestXX#test_something = 0.00 s = .
FakeNamedTestXX#test_skip = 0.00 s = S
Finished in 0.00
1) Skipped:
FakeNamedTestXX#test_skip [FILE:LINE]:
not yet
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
EOM
assert_report expected, %w[--seed 42 --verbose]
end
|
#test_run_test ⇒ Object
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 217
def test_run_test
@tu =
Class.new FakeNamedTest do
attr_reader :foo
def run
@foo = "hi mom!"
r = super
@foo = "okay"
r
end
def test_something
assert_equal "hi mom!", foo
end
end
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected
end
|
#test_run_with_other_runner ⇒ Object
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 563
def test_run_with_other_runner
@tu =
Class.new FakeNamedTest do
def self.run reporter, options = {}
@reporter = reporter
before_my_suite
super
end
def self.name; "wacky!" end
def self.before_my_suite
@reporter.io.puts "Running #{self.name} tests"
@@foo = 1
end
def test_something
assert_equal 1, @@foo
end
def test_something_else
assert_equal 1, @@foo
end
end
expected = clean <<-EOM
Running wacky! tests
..
Finished in 0.00
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected
end
|
#test_seed ⇒ Object
this is set for THIS run, so I’m not testing it’s actual value
333
334
335
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 333
def test_seed assert_instance_of Integer, Minitest.seed
end
|