Class: Test::Unit::Failure
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/test/unit/failure.rb |
Overview
Encapsulates a test failure. Created by TestCase
when an assertion fails.
Constant Summary
-
LABEL =
# File 'lib/test/unit/failure.rb', line 19"Failure"
-
SINGLE_CHARACTER =
# File 'lib/test/unit/failure.rb', line 18'F'
Class Method Summary
-
.new(test_name, location, message, options = {}) ⇒ Failure
constructor
Creates a new
Failure
with the given location and message.
Instance Attribute Summary
- #actual readonly
- #critical? ⇒ Boolean readonly
- #expected readonly
- #inspected_actual readonly
- #inspected_expected readonly
- #location readonly
- #message readonly
- #method_name readonly
- #source_location readonly
- #test_name readonly
- #user_message readonly
Instance Method Summary
- #diff
- #label
-
#long_display
Returns a verbose version of the error description.
-
#short_display
Returns a brief version of the error description.
-
#single_character_display
Returns a single character representation of a failure.
-
#to_s
Overridden to return long_display.
- #compute_diff private
Constructor Details
.new(test_name, location, message, options = {}) ⇒ Failure
Creates a new Failure
with the given location and message.
# File 'lib/test/unit/failure.rb', line 23
def initialize(test_name, location, , ={}) @test_name = test_name @location = location @message = @method_name = [:method_name] @source_location = [:source_location] @expected = [:expected] @actual = [:actual] @inspected_expected = [:inspected_expected] @inspected_actual = [:inspected_actual] @user_message = [: ] end
Instance Attribute Details
#actual (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 15
attr_reader :expected, :actual, :
#critical? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/test/unit/failure.rb', line 65
def critical? true end
#expected (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 15
attr_reader :expected, :actual, :
#inspected_actual (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 16
attr_reader :inspected_expected, :inspected_actual
#inspected_expected (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 16
attr_reader :inspected_expected, :inspected_actual
#location (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 13
attr_reader :test_name, :location, :
#message (readonly)
[ GitHub ]#method_name (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 14
attr_reader :method_name, :source_location
#source_location (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 14
attr_reader :method_name, :source_location
#test_name (readonly)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 13
attr_reader :test_name, :location, :
#user_message (readonly)
[ GitHub ]Instance Method Details
#compute_diff (private)
[ GitHub ]# File 'lib/test/unit/failure.rb', line 74
def compute_diff Assertions::AssertionMessage.delayed_diff(@expected, @actual).inspect end
#diff
[ GitHub ]# File 'lib/test/unit/failure.rb', line 69
def diff @diff ||= compute_diff end
#label
[ GitHub ]# File 'lib/test/unit/failure.rb', line 41
def label LABEL end
#long_display
Returns a verbose version of the error description.
#short_display
Returns a brief version of the error description.
# File 'lib/test/unit/failure.rb', line 46
def short_display "#@test_name: #{@message.split("\n")[0]}" end
#single_character_display
Returns a single character representation of a failure.
# File 'lib/test/unit/failure.rb', line 37
def single_character_display SINGLE_CHARACTER end
#to_s
Overridden to return long_display.
# File 'lib/test/unit/failure.rb', line 61
def to_s long_display end