Class: Test::Unit::Error
- Inherits:
-
Object
- Object
- Test::Unit::Error
- Includes:
- Util::BacktraceFilter
- Defined in:
- lib/test/unit/error.rb
Overview
Encapsulates an error in a test. Created by Test::Unit::TestCase when it rescues an exception thrown during the processing of a test.
Constant Summary collapse
- SINGLE_CHARACTER =
'E'
Constants included from Util::BacktraceFilter
Util::BacktraceFilter::TESTUNIT_FILE_SEPARATORS, Util::BacktraceFilter::TESTUNIT_PREFIX, Util::BacktraceFilter::TESTUNIT_RB_FILE
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#test_name ⇒ Object
readonly
Returns the value of attribute test_name.
Instance Method Summary collapse
-
#initialize(test_name, exception) ⇒ Error
constructor
Creates a new Error with the given test_name and exception.
-
#long_display ⇒ Object
Returns a verbose version of the error description.
-
#message ⇒ Object
Returns the message associated with the error.
-
#short_display ⇒ Object
Returns a brief version of the error description.
-
#single_character_display ⇒ Object
Returns a single character representation of an error.
-
#to_s ⇒ Object
Overridden to return long_display.
Methods included from Util::BacktraceFilter
Constructor Details
#initialize(test_name, exception) ⇒ Error
Creates a new Error with the given test_name and exception.
24 25 26 27 |
# File 'lib/test/unit/error.rb', line 24 def initialize(test_name, exception) @test_name = test_name @exception = exception end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
18 19 20 |
# File 'lib/test/unit/error.rb', line 18 def exception @exception end |
#test_name ⇒ Object (readonly)
Returns the value of attribute test_name.
18 19 20 |
# File 'lib/test/unit/error.rb', line 18 def test_name @test_name end |
Instance Method Details
#long_display ⇒ Object
Returns a verbose version of the error description.
45 46 47 48 |
# File 'lib/test/unit/error.rb', line 45 def long_display backtrace = filter_backtrace(@exception.backtrace).join("\n ") "Error:\n#@test_name:\n#{}\n #{backtrace}" end |
#message ⇒ Object
Returns the message associated with the error.
35 36 37 |
# File 'lib/test/unit/error.rb', line 35 def "#{@exception.class.name}: #{@exception.}" end |
#short_display ⇒ Object
Returns a brief version of the error description.
40 41 42 |
# File 'lib/test/unit/error.rb', line 40 def short_display "#@test_name: #{.split("\n")[0]}" end |
#single_character_display ⇒ Object
Returns a single character representation of an error.
30 31 32 |
# File 'lib/test/unit/error.rb', line 30 def single_character_display SINGLE_CHARACTER end |
#to_s ⇒ Object
Overridden to return long_display.
51 52 53 |
# File 'lib/test/unit/error.rb', line 51 def to_s long_display end |