class Test::Unit::Error

Encapsulates an error in a test. Created by Test::Unit::TestCase when it rescues an exception thrown during the processing of a test.

Constants

LABEL
SINGLE_CHARACTER

Attributes

exception[R]
method_name[R]
test_name[R]

Public Class Methods

new(test_name, exception, options={}) click to toggle source

Creates a new Error with the given #test_name and exception.

# File lib/test/unit/error.rb, line 26
def initialize(test_name, exception, options={})
  @test_name = test_name
  @exception = exception
  @method_name = options[:method_name]
end

Public Instance Methods

backtrace()
Alias for: location
critical?() click to toggle source
# File lib/test/unit/error.rb, line 67
def critical?
  true
end
label() click to toggle source
# File lib/test/unit/error.rb, line 37
def label
  LABEL
end
location() click to toggle source
# File lib/test/unit/error.rb, line 57
def location
  @location ||= filter_backtrace(@exception.backtrace)
end
Also aliased as: backtrace
long_display() click to toggle source

Returns a verbose version of the error description.

# File lib/test/unit/error.rb, line 52
def long_display
  backtrace_display = location.join("\n    ")
  "#{label}:\n#@test_name:\n#{message}\n    #{backtrace_display}"
end
message() click to toggle source

Returns the message associated with the error.

# File lib/test/unit/error.rb, line 42
def message
  "#{@exception.class.name}: #{@exception.message}"
end
short_display() click to toggle source

Returns a brief version of the error description.

# File lib/test/unit/error.rb, line 47
def short_display
  "#@test_name: #{message.split("\n")[0]}"
end
single_character_display() click to toggle source

Returns a single character representation of an error.

# File lib/test/unit/error.rb, line 33
def single_character_display
  SINGLE_CHARACTER
end
to_s() click to toggle source

Overridden to return long_display.

# File lib/test/unit/error.rb, line 63
def to_s
  long_display
end