Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • test/unit/error.rb

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

SINGLE_CHARACTER

Attributes

exception[R]
test_name[R]

Public Class Methods

new(test_name, exception) click to toggle source

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

 
               # File test/unit/error.rb, line 24
def initialize(test_name, exception)
  @test_name = test_name
  @exception = exception
end
            

Public Instance Methods

long_display() click to toggle source

Returns a verbose version of the error description.

 
               # File test/unit/error.rb, line 45
def long_display
  backtrace = filter_backtrace(@exception.backtrace).join("\n    ")
  "Error:\n#@test_name:\n#{message}\n    #{backtrace}"
end
            
message() click to toggle source

Returns the message associated with the error.

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

Returns a brief version of the error description.

 
               # File test/unit/error.rb, line 40
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 test/unit/error.rb, line 30
def single_character_display
  SINGLE_CHARACTER
end
            
to_s() click to toggle source

Overridden to return long_display.

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

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus