Class: Test::Unit::Failure
- Inherits:
-
Object
- Object
- Test::Unit::Failure
- Defined in:
- lib/test/unit/failure.rb
Overview
Encapsulates a test failure. Created by Test::Unit::TestCase when an assertion fails.
Constant Summary
- SINGLE_CHARACTER =
'F'- LABEL =
"Failure"
Instance Attribute Summary (collapse)
-
- (Object) actual
readonly
Returns the value of attribute actual.
-
- (Object) expected
readonly
Returns the value of attribute expected.
-
- (Object) inspected_actual
readonly
Returns the value of attribute inspected_actual.
-
- (Object) inspected_expected
readonly
Returns the value of attribute inspected_expected.
-
- (Object) location
readonly
Returns the value of attribute location.
-
- (Object) message
readonly
Returns the value of attribute message.
-
- (Object) method_name
readonly
Returns the value of attribute method_name.
-
- (Object) source_location
readonly
Returns the value of attribute source_location.
-
- (Object) test_name
readonly
Returns the value of attribute test_name.
-
- (Object) user_message
readonly
Returns the value of attribute user_message.
Instance Method Summary (collapse)
- - (Boolean) critical?
- - (Object) diff
-
- (Failure) initialize(test_name, location, message, options = {})
constructor
Creates a new Failure with the given location and message.
- - (Object) label
-
- (Object) long_display
Returns a verbose version of the error description.
-
- (Object) short_display
Returns a brief version of the error description.
-
- (Object) single_character_display
Returns a single character representation of a failure.
-
- (Object) to_s
Overridden to return long_display.
Constructor Details
- (Failure) initialize(test_name, location, message, options = {})
Creates a new Failure with the given location and message.
23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 = [:user_message] end |
Instance Attribute Details
- (Object) actual (readonly)
Returns the value of attribute actual
15 16 17 |
# File 'lib/test/unit/failure.rb', line 15 def actual @actual end |
- (Object) expected (readonly)
Returns the value of attribute expected
15 16 17 |
# File 'lib/test/unit/failure.rb', line 15 def expected @expected end |
- (Object) inspected_actual (readonly)
Returns the value of attribute inspected_actual
16 17 18 |
# File 'lib/test/unit/failure.rb', line 16 def inspected_actual @inspected_actual end |
- (Object) inspected_expected (readonly)
Returns the value of attribute inspected_expected
16 17 18 |
# File 'lib/test/unit/failure.rb', line 16 def inspected_expected @inspected_expected end |
- (Object) location (readonly)
Returns the value of attribute location
13 14 15 |
# File 'lib/test/unit/failure.rb', line 13 def location @location end |
- (Object) message (readonly)
Returns the value of attribute message
13 14 15 |
# File 'lib/test/unit/failure.rb', line 13 def @message end |
- (Object) method_name (readonly)
Returns the value of attribute method_name
14 15 16 |
# File 'lib/test/unit/failure.rb', line 14 def method_name @method_name end |
- (Object) source_location (readonly)
Returns the value of attribute source_location
14 15 16 |
# File 'lib/test/unit/failure.rb', line 14 def source_location @source_location end |
- (Object) test_name (readonly)
Returns the value of attribute test_name
13 14 15 |
# File 'lib/test/unit/failure.rb', line 13 def test_name @test_name end |
- (Object) user_message (readonly)
Returns the value of attribute user_message
15 16 17 |
# File 'lib/test/unit/failure.rb', line 15 def @user_message end |
Instance Method Details
- (Boolean) critical?
65 66 67 |
# File 'lib/test/unit/failure.rb', line 65 def critical? true end |
- (Object) diff
69 70 71 |
# File 'lib/test/unit/failure.rb', line 69 def diff @diff ||= compute_diff end |
- (Object) label
41 42 43 |
# File 'lib/test/unit/failure.rb', line 41 def label LABEL end |
- (Object) long_display
Returns a verbose version of the error description.
51 52 53 54 55 56 57 58 |
# File '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 |
- (Object) short_display
Returns a brief version of the error description.
46 47 48 |
# File 'lib/test/unit/failure.rb', line 46 def short_display "#@test_name: #{@message.split("\n")[0]}" end |
- (Object) single_character_display
Returns a single character representation of a failure.
37 38 39 |
# File 'lib/test/unit/failure.rb', line 37 def single_character_display SINGLE_CHARACTER end |
- (Object) to_s
Overridden to return long_display.
61 62 63 |
# File 'lib/test/unit/failure.rb', line 61 def to_s long_display end |