class Test::Unit::Failure
封装测试失败。当断言失败时,由Test::Unit::TestCase
创建。
常量
- LABEL
- SINGLE_CHARACTER
属性
actual[R]
expected[R]
inspected_actual[R]
inspected_expected[R]
location[R]
message[R]
method_name[R]
source_location[R]
test_name[R]
user_message[R]
公共类方法
new(test_name, location, message, options={}) 点击以切换源代码
使用给定的位置和消息创建一个新的 Failure
。
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 23 def initialize(test_name, location, message, options={}) @test_name = test_name @location = location @message = message @method_name = options[:method_name] @source_location = options[:source_location] @expected = options[:expected] @actual = options[:actual] @inspected_expected = options[:inspected_expected] @inspected_actual = options[:inspected_actual] @user_message = options[:user_message] end
公共实例方法
critical?() 点击以切换源代码
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 65 def critical? true end
diff() 点击以切换源代码
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 69 def diff @diff ||= compute_diff end
label() 点击以切换源代码
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 41 def label LABEL end
long_display() 点击以切换源代码
返回错误描述的详细版本。
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 51 def long_display if location.size == 1 location_display = location[0].sub(/\A(.+:\d+).*/, ' [\\1]') else location_display = "\n [#{location.join("\n ")}]" end "#{label}:\n#@test_name#{location_display}:\n#@message" end
short_display() 点击以切换源代码
返回错误描述的简短版本。
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 46 def short_display "#@test_name: #{@message.split("\n")[0]}" end
single_character_display() 点击以切换源代码
返回失败的单字符表示形式。
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 37 def single_character_display SINGLE_CHARACTER end
to_s() 点击以切换源代码
重写以返回 long_display。
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 61 def to_s long_display end
私有实例方法
compute_diff() 点击以切换源代码
# File test-unit-3.6.7/lib/test/unit/failure.rb, line 74 def compute_diff Assertions::AssertionMessage.delayed_diff(@expected, @actual).inspect end