123456789_123456789_123456789_123456789_123456789_

Class: Test::Unit::Error

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/test/unit/error.rb

Overview

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

Constant Summary

Util::BacktraceFilter - Included

TESTUNIT_FILE_SEPARATORS, TESTUNIT_PREFIX, TESTUNIT_RB_FILE

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Util::BacktraceFilter - Included

Constructor Details

.new(test_name, exception, options = {}) ⇒ Error

Creates a new Error with the given test_name and exception.

[ GitHub ]

  
# 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

Instance Attribute Details

#critical?Boolean (readonly)

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 67

def critical?
  true
end

#exception (readonly)

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 18

attr_reader :test_name, :exception

#method_name (readonly)

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 19

attr_reader :method_name

#test_name (readonly)

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 18

attr_reader :test_name, :exception

Instance Method Details

#backtrace

Alias for #location.

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 60

alias_method :backtrace, :location # Deprecated

#label

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 37

def label
  LABEL
end

#location Also known as: #backtrace

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 57

def location
  @location ||= filter_backtrace(@exception.backtrace)
end

#long_display

Returns a verbose version of the error description.

[ GitHub ]

  
# 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

Returns the message associated with the error.

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 42

def message
  "#{@exception.class.name}: #{@exception.message}"
end

#short_display

Returns a brief version of the error description.

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 47

def short_display
  "#@test_name: #{message.split("\n")[0]}"
end

#single_character_display

Returns a single character representation of an error.

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 33

def single_character_display
  SINGLE_CHARACTER
end

#to_s

Overridden to return long_display.

[ GitHub ]

  
# File 'lib/test/unit/error.rb', line 63

def to_s
  long_display
end