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
- SINGLE_CHARACTER =
'E'- LABEL =
"Error"
Constants included from Util::BacktraceFilter
Util::BacktraceFilter::TESTUNIT_FILE_SEPARATORS, Util::BacktraceFilter::TESTUNIT_PREFIX, Util::BacktraceFilter::TESTUNIT_RB_FILE
Instance Attribute Summary (collapse)
-
- (Object) exception
readonly
Returns the value of attribute exception.
-
- (Object) method_name
readonly
Returns the value of attribute method_name.
-
- (Object) test_name
readonly
Returns the value of attribute test_name.
Instance Method Summary (collapse)
- - (Boolean) critical?
-
- (Error) initialize(test_name, exception, options = {})
constructor
Creates a new Error with the given test_name and exception.
- - (Object) label
- - (Object) location (also: #backtrace)
-
- (Object) long_display
Returns a verbose version of the error description.
-
- (Object) message
Returns the message associated with the error.
-
- (Object) short_display
Returns a brief version of the error description.
-
- (Object) single_character_display
Returns a single character representation of an error.
-
- (Object) to_s
Overridden to return long_display.
Methods included from Util::BacktraceFilter
Constructor Details
- (Error) initialize(test_name, exception, options = {})
Creates a new Error with the given test_name and exception.
26 27 28 29 30 |
# File 'lib/test/unit/error.rb', line 26 def initialize(test_name, exception, ={}) @test_name = test_name @exception = exception @method_name = [:method_name] end |
Instance Attribute Details
- (Object) exception (readonly)
Returns the value of attribute exception
18 19 20 |
# File 'lib/test/unit/error.rb', line 18 def exception @exception end |
- (Object) method_name (readonly)
Returns the value of attribute method_name
19 20 21 |
# File 'lib/test/unit/error.rb', line 19 def method_name @method_name end |
- (Object) test_name (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
- (Boolean) critical?
67 68 69 |
# File 'lib/test/unit/error.rb', line 67 def critical? true end |
- (Object) label
37 38 39 |
# File 'lib/test/unit/error.rb', line 37 def label LABEL end |
- (Object) location Also known as: backtrace
57 58 59 |
# File 'lib/test/unit/error.rb', line 57 def location @location ||= filter_backtrace(@exception.backtrace) end |
- (Object) long_display
Returns a verbose version of the error description.
52 53 54 55 |
# File 'lib/test/unit/error.rb', line 52 def long_display backtrace_display = location.join("\n ") "#{label}:\n#@test_name:\n#{}\n #{backtrace_display}" end |
- (Object) message
Returns the message associated with the error.
42 43 44 |
# File 'lib/test/unit/error.rb', line 42 def "#{@exception.class.name}: #{@exception.}" end |
- (Object) short_display
Returns a brief version of the error description.
47 48 49 |
# File 'lib/test/unit/error.rb', line 47 def short_display "#@test_name: #{.split("\n")[0]}" end |
- (Object) single_character_display
Returns a single character representation of an error.
33 34 35 |
# File 'lib/test/unit/error.rb', line 33 def single_character_display SINGLE_CHARACTER end |
- (Object) to_s
Overridden to return long_display.
63 64 65 |
# File 'lib/test/unit/error.rb', line 63 def to_s long_display end |