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

In Files

  • test/unit/failure.rb

Test::Unit::Failure

Encapsulates a test failure. Created by Test::Unit::TestCase when an assertion fails.

Constants

SINGLE_CHARACTER

Attributes

location[R]
message[R]
test_name[R]

Public Class Methods

new(test_name, location, message) click to toggle source

Creates a new Failure with the given location and message.

 
               # File test/unit/failure.rb, line 19
def initialize(test_name, location, message)
  @test_name = test_name
  @location = location
  @message = message
end
            

Public Instance Methods

long_display() click to toggle source

Returns a verbose version of the error description.

 
               # File test/unit/failure.rb, line 36
def long_display
  location_display = if(location.size == 1)
    location[0].sub(/\A(.+:\d+).*/, ' [\1]')
  else
    "\n    [#{location.join("\n     ")}]"
  end
  "Failure:\n#@test_name#{location_display}:\n#@message"
end
            
short_display() click to toggle source

Returns a brief version of the error description.

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

Returns a single character representation of a failure.

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

Overridden to return long_display.

 
               # File test/unit/failure.rb, line 46
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