Encapsulates a test failure. Created by Test::Unit::TestCase when an assertion fails.
Creates a new Failure with the given location and message.
# File test-unit-3.3.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
# File test-unit-3.3.7/lib/test/unit/failure.rb, line 65 def critical? true end
# File test-unit-3.3.7/lib/test/unit/failure.rb, line 69 def diff @diff ||= compute_diff end
# File test-unit-3.3.7/lib/test/unit/failure.rb, line 41 def label LABEL end
Returns a verbose version of the error description.
# File test-unit-3.3.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
Returns a brief version of the error description.
# File test-unit-3.3.7/lib/test/unit/failure.rb, line 46 def short_display "#@test_name: #{@message.split("\n")[0]}" end