Class Test::Unit::Failure
In: test/unit/failure.rb
Parent: Object

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

Methods

Constants

SINGLE_CHARACTER = 'F'

Attributes

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

Public Class methods

Creates a new Failure with the given location and message.

[Source]

# 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

Returns a verbose version of the error description.

[Source]

# 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

Returns a brief version of the error description.

[Source]

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

Returns a single character representation of a failure.

[Source]

# File test/unit/failure.rb, line 26
      def single_character_display
        SINGLE_CHARACTER
      end

Overridden to return long_display.

[Source]

# File test/unit/failure.rb, line 46
      def to_s
        long_display
      end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Neurogami, LLC, a Ruby consulting company. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

For information about this site or Neurogami, contact james@neurogami.com.