Class: Test::Unit::Notification

Inherits:
Object
  • Object
show all
Includes:
Util::BacktraceFilter
Defined in:
lib/test/unit/notification.rb

Constant Summary

SINGLE_CHARACTER =
'N'
LABEL =
"Notification"

Constants included from Util::BacktraceFilter

Util::BacktraceFilter::TESTUNIT_FILE_SEPARATORS, Util::BacktraceFilter::TESTUNIT_PREFIX, Util::BacktraceFilter::TESTUNIT_RB_FILE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::BacktraceFilter

filter_backtrace

Constructor Details

#initialize(test_name, location, message, options = {}) ⇒ Notification

Creates a new Notification with the given location and message.



15
16
17
18
19
20
# File 'lib/test/unit/notification.rb', line 15

def initialize(test_name, location, message, options={})
  @test_name = test_name
  @location = location
  @message = message
  @method_name = options[:method_name]
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location



7
8
9
# File 'lib/test/unit/notification.rb', line 7

def location
  @location
end

#messageObject (readonly)

Returns the value of attribute message



7
8
9
# File 'lib/test/unit/notification.rb', line 7

def message
  @message
end

#method_nameObject (readonly)

Returns the value of attribute method_name



8
9
10
# File 'lib/test/unit/notification.rb', line 8

def method_name
  @method_name
end

#test_nameObject (readonly)

Returns the value of attribute test_name



7
8
9
# File 'lib/test/unit/notification.rb', line 7

def test_name
  @test_name
end

Instance Method Details

#critical?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/test/unit/notification.rb', line 47

def critical?
  false
end

#labelObject



27
28
29
# File 'lib/test/unit/notification.rb', line 27

def label
  LABEL
end

#long_displayObject

Returns a verbose version of the error description.



37
38
39
40
# File 'lib/test/unit/notification.rb', line 37

def long_display
  backtrace = filter_backtrace(location).join("\n")
  "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
end

#short_displayObject

Returns a brief version of the error description.



32
33
34
# File 'lib/test/unit/notification.rb', line 32

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

#single_character_displayObject

Returns a single character representation of a notification.



23
24
25
# File 'lib/test/unit/notification.rb', line 23

def single_character_display
  SINGLE_CHARACTER
end

#to_sObject

Overridden to return long_display.



43
44
45
# File 'lib/test/unit/notification.rb', line 43

def to_s
  long_display
end