class TestMinitestRunner
Public Class Methods
before_my_suite()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 537 def self.before_my_suite @reporter.io.puts "Running #{self.name} tests" @@foo = 1 end
name()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 535 def self.name; "wacky!" end
run(reporter, options = {})
click to toggle source
Calls superclass method
Minitest::Test#run
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 529 def self.run reporter, options = {} @reporter = reporter before_my_suite super end
Public Instance Methods
assert_filtering(filter, name, expected, a = false)
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 341 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
run()
click to toggle source
Calls superclass method
Minitest::Test#run
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 216 def run @foo = "hi mom!" r = super @foo = "okay" r end
setup_basic_tu()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 314 def setup_basic_tu @tu = Class.new FakeNamedTest do def test_something assert true end def test_failure assert false end end end
teardown()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 275 def teardown raise "unhandled exception" end
test_class_runnables()
click to toggle source
do not parallelize this suite… it just can’t handle it.
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 202 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_error()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 247 def test_error raise "unhandled exception" end
test_failure()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 321 def test_failure assert false end
test_run_error()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 240 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 268 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 296 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 402 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 327 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 440 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 416 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 428 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 366 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 378 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 390 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 584 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 # This latch waits until both test latches have been released. Both # latches can't be released unless done in separate threads because # `main_latch` keeps the test method from finishing. 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 # This latch blocks until the "main thread" releases it. The main # thread can't release this latch until both test latches have # been released. This forces the latches to be released in separate # threads. 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 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 452 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 471 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_verbose()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 498 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_skip = 0.00 s = S FakeNamedTestXX#test_something = 0.00 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 211 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()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 526 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_skip()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 478 def test_skip skip "not yet" end
test_something()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 224 def test_something assert_equal "hi mom!", foo end
test_something_else()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 546 def test_something_else assert_equal 1, @@foo end