class Test::Unit::AssertionFailedError

当断言失败时,由 Test::Unit::Assertions 抛出。

属性

actual[RW]
expected[RW]
inspected_actual[RW]
inspected_expected[RW]
user_message[RW]

公共类方法

debug_on_failure=(boolean) 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/assertion-failed-error.rb, line 14
def debug_on_failure=(boolean)
  @debug_on_failure = boolean
end
debug_on_failure?() 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/assertion-failed-error.rb, line 18
def debug_on_failure?
  @debug_on_failure
end
new(message=nil, options=nil) 点击切换源代码
调用父类方法
# File test-unit-3.6.7/lib/test/unit/assertion-failed-error.rb, line 25
def initialize(message=nil, options=nil)
  options ||= {}
  @expected = options[:expected]
  @actual = options[:actual]
  @inspected_expected = options[:inspected_expected]
  @inspected_actual = options[:inspected_actual]
  @user_message = options[:user_message]
  super(message)
  debug_on_failure
end

私有实例方法

debug_on_failure() 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/assertion-failed-error.rb, line 37
def debug_on_failure
  return unless self.class.debug_on_failure?

  begin
    require "debug"
  rescue LoadError
    return
  end

  return unless binding.respond_to?(:break)

  frames = caller(0)
  pre = nil
  Util::BacktraceFilter.filter_backtrace(frames).each do |location|
    frame_index = frames.index(location)
    next if frame_index.nil?
    pre = "frame #{frame_index}"
    break
  end
  binding.break(pre: pre)
end