class TestUnitEmacsRunner

Public Instance Methods

test_format_error() click to toggle source
# File test-unit-3.3.4/test/test-emacs-runner.rb, line 37
  def test_format_error
    runner = create_runner
    test_name = "test_error"
    message = "Error Message!!!"
    backtrace = ["/home/user/test_xxx.rb:3: in `xxx'",
                 "/home/user/yyy/test_yyy.rb:999: in `yyy'",
                 "/home/user/xyz/zzz.rb:29: in `zzz'"]
    exception = RuntimeError.new(message)
    exception.set_backtrace(backtrace)
    error = Test::Unit::Error.new(test_name, exception)
    assert_equal(<<-EOM.chomp, runner.send(:format_fault, error))
Error:
#{test_name}:
#{exception.class.name}: #{message}
#{backtrace.join("\n")}
EOM
  end
test_format_failure_with_a_location() click to toggle source
# File test-unit-3.3.4/test/test-emacs-runner.rb, line 5
  def test_format_failure_with_a_location
    runner = create_runner
    test_name = "test_failure"
    file = "/home/user/test_xxx.rb"
    line = "3"
    info = "in `xxx'"
    location = "#{file}:#{line}: #{info}"
    message = "FAIL!!!"
    failure = Test::Unit::Failure.new(test_name, [location], message)
    assert_equal(<<-EOM.chomp, runner.send(:format_fault, failure))
Failure:
#{test_name} [#{file}:#{line}]:
#{message}
EOM
  end
test_format_failure_with_locations() click to toggle source
# File test-unit-3.3.4/test/test-emacs-runner.rb, line 21
  def test_format_failure_with_locations
    runner = create_runner
    test_name = "test_failure"
    locations = ["/home/user/test_xxx.rb:3: in `xxx'",
                 "/home/user/yyy/test_yyy.rb:999: in `yyy'",
                 "/home/user/xyz/zzz.rb:29: in `zzz'"]
    message = "Many backtrace!!!"
    failure = Test::Unit::Failure.new(test_name, locations, message)
    assert_equal(<<-EOM.chomp, runner.send(:format_fault, failure))
Failure:
#{test_name}
#{locations.join("\n")}:
#{message}
EOM
  end

Private Instance Methods

create_runner(suite=nil) click to toggle source
# File test-unit-3.3.4/test/test-emacs-runner.rb, line 56
def create_runner(suite=nil)
  suite ||= Test::Unit::TestSuite.new
  Test::Unit::UI::Emacs::TestRunner.new(suite)
end