Class: Test::Unit::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/test-unit-ext/pending.rb,
lib/test-unit-ext/xml-report.rb,
lib/test-unit-ext/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestResult

Returns a new instance of TestResult.



7
8
9
10
# File 'lib/test-unit-ext/pending.rb', line 7

def initialize
  initialize_without_pendings
  @pendings = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



154
155
156
# File 'lib/test-unit-ext/xml-report.rb', line 154

def errors
  @errors
end

#failuresObject (readonly)

Returns the value of attribute failures.



154
155
156
# File 'lib/test-unit-ext/xml-report.rb', line 154

def failures
  @failures
end

#notificationsObject (readonly)

Returns the value of attribute notifications.



4
5
6
# File 'lib/test-unit-ext/notification.rb', line 4

def notifications
  @notifications
end

#pendingsObject (readonly)

Returns the value of attribute pendings.



4
5
6
# File 'lib/test-unit-ext/pending.rb', line 4

def pendings
  @pendings
end

Instance Method Details

#add_error(error) ⇒ Object



175
176
177
178
# File 'lib/test-unit-ext/xml-report.rb', line 175

def add_error(error)
  @logs << error
  add_error_without_logs_store(error)
end

#add_error_without_logs_storeObject



174
# File 'lib/test-unit-ext/xml-report.rb', line 174

alias_method(:add_error_without_logs_store, :add_error)

#add_failure(failure) ⇒ Object



169
170
171
172
# File 'lib/test-unit-ext/xml-report.rb', line 169

def add_failure(failure)
  @logs << failure
  add_failure_without_logs_store(failure)
end

#add_failure_without_logs_storeObject



168
# File 'lib/test-unit-ext/xml-report.rb', line 168

alias_method(:add_failure_without_logs_store, :add_failure)

#add_notification(notification) ⇒ Object



12
13
14
15
16
# File 'lib/test-unit-ext/notification.rb', line 12

def add_notification(notification)
  @notifications << notification
  notify_listeners(FAULT, notification)
  notify_listeners(CHANGED, self)
end

#add_pending(pending) ⇒ Object



12
13
14
15
16
# File 'lib/test-unit-ext/pending.rb', line 12

def add_pending(pending)
  @pendings << pending
  notify_listeners(FAULT, pending)
  notify_listeners(CHANGED, self)
end

#add_success(success) ⇒ Object



163
164
165
166
# File 'lib/test-unit-ext/xml-report.rb', line 163

def add_success(success)
  @logs << success
  @successes << success
end

#initialize_without_notificationsTestResult

Returns a new instance of TestResult.

Returns:



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

def initialize
  initialize_without_pendings
  @pendings = []
end

#initialize_without_pendingsObject



6
# File 'lib/test-unit-ext/pending.rb', line 6

alias_method(:initialize_without_pendings, :initialize)

#initialize_without_successesTestResult

Returns a new instance of TestResult.

Returns:



156
157
158
159
# File 'lib/test-unit-ext/xml-report.rb', line 156

def initialize
  initialize_without_pendings
  @pendings = []
end

#notification_countObject



18
19
20
# File 'lib/test-unit-ext/notification.rb', line 18

def notification_count
  @notifications.size
end

#pending_countObject



18
19
20
# File 'lib/test-unit-ext/pending.rb', line 18

def pending_count
  @pendings.size
end

#to_sObject



23
24
25
# File 'lib/test-unit-ext/pending.rb', line 23

def to_s
  to_s_without_pendings + ", #{pending_count} pendings"
end

#to_s_without_notificationsObject



22
23
24
# File 'lib/test-unit-ext/notification.rb', line 22

def to_s
  to_s_without_pendings + ", #{pending_count} pendings"
end

#to_s_without_pendingsObject



22
# File 'lib/test-unit-ext/pending.rb', line 22

alias_method(:to_s_without_pendings, :to_s)

#to_xmlObject



180
181
182
183
184
# File 'lib/test-unit-ext/xml-report.rb', line 180

def to_xml
  return "<report/>" if @logs.empty?
  xml = @logs.collect {|log| log.to_xml.gsub(/^/, "  ")}.join
  "<report>\n#{xml}</report>\n"
end