class TestMinitestUnitRecording

Public Instance Methods

assert_run_record(*expected, &block) 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 958
def assert_run_record *expected, &block
  @tu = Class.new FakeNamedTest, &block

  run_tu_with_fresh_reporter

  recorded = first_reporter.results.map(&:failures).flatten.map { |f| f.error.class }

  assert_equal expected, recorded
end
passed?() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 982
def passed?; end
record(result;) click to toggle source

def prerecord klass, name; end # doesn’t define full API

# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 980
def record result; @success = true; end
report() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 981
def report; end
results() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 983
def results; end
start() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 978
def start; @success = false; end
success?() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 984
def success?; @success; end
teardown() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1027
def teardown
  raise "unhandled exception"
end
test_method() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 972
def test_method
  assert true
end
test_record_error() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1013
def test_record_error
  assert_run_record RuntimeError do
    def test_method
      raise "unhandled exception"
    end
  end
end
test_record_error_in_test_and_teardown() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1033
def test_record_error_in_test_and_teardown
  assert_run_record AnError, RuntimeError do
    def test_method
      raise AnError
    end

    def teardown
      raise "unhandled exception"
    end
  end
end
test_record_error_teardown() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1021
def test_record_error_teardown
  assert_run_record RuntimeError do
    def test_method
      assert true
    end

    def teardown
      raise "unhandled exception"
    end
  end
end
test_record_failing() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1005
def test_record_failing
  assert_run_record Minitest::Assertion do
    def test_method
      assert false
    end
  end
end
test_record_passing() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 997
def test_record_passing
  assert_run_record do
    def test_method
      assert true
    end
  end
end
test_record_skip() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1073
def test_record_skip
  assert_run_record Minitest::Skip do
    def test_method
      skip "not yet"
    end
  end
end
test_run_with_bogus_reporter() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 968
def test_run_with_bogus_reporter
  # https://github.com/seattlerb/minitest/issues/659
  # TODO: remove test for minitest 6
  @tu = Class.new FakeNamedTest do
    def test_method
      assert true
    end
  end

  bogus_reporter = Class.new do      # doesn't subclass AbstractReporter
    def start; @success = false; end
    # def prerecord klass, name; end # doesn't define full API
    def record result; @success = true; end
    def report; end
    def passed?; end
    def results; end
    def success?; @success; end
  end.new

  self.reporter = Minitest::CompositeReporter.new
  reporter << bogus_reporter

  Minitest::Runnable.runnables.delete @tu

  @tu.run reporter, {}

  assert_predicate bogus_reporter, :success?
end
test_to_s_error_in_test_and_teardown() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 1045
def test_to_s_error_in_test_and_teardown
  @tu = Class.new FakeNamedTest do
    def test_method
      raise AnError
    end

    def teardown
      raise "unhandled exception"
    end
  end

  run_tu_with_fresh_reporter

  exp = clean "
    Error:
    FakeNamedTestXX#test_method:
    AnError: AnError
        FILE:LINE:in `test_method'

    Error:
    FakeNamedTestXX#test_method:
    RuntimeError: unhandled exception
        FILE:LINE:in `teardown'
  "

  assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
end