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

In Files

  • test/unit/testresult.rb
  • test/unit/ui/console/testrunner.rb
  • test/unit/ui/fox/testrunner.rb
  • test/unit/ui/gtk/testrunner.rb
  • test/unit/ui/gtk2/testrunner.rb
  • test/unit/ui/testrunnermediator.rb
  • test/unit/ui/tk/testrunner.rb


Collects Test::Unit::Failure and Test::Unit::Error so that they can be displayed to the user. To this end, observers can be added to it, allowing the dynamic updating of, say, a UI.





Public Class Methods

new() click to toggle source

Constructs a new, empty TestResult.

               # File test/unit/testresult.rb, line 24
def initialize
  @run_count, @assertion_count = 0, 0
  @failures, @errors = Array.new, Array.new

Public Instance Methods

add_assertion() click to toggle source

Records an individual assertion.

               # File test/unit/testresult.rb, line 50
def add_assertion
  @assertion_count += 1
  notify_listeners(CHANGED, self)
add_error(error) click to toggle source

Records a Test::Unit::Error.

               # File test/unit/testresult.rb, line 43
def add_error(error)
  @errors << error
  notify_listeners(FAULT, error)
  notify_listeners(CHANGED, self)
add_failure(failure) click to toggle source

Records a Test::Unit::Failure.

               # File test/unit/testresult.rb, line 36
def add_failure(failure)
  @failures << failure
  notify_listeners(FAULT, failure)
  notify_listeners(CHANGED, self)
add_run() click to toggle source

Records a test run.

               # File test/unit/testresult.rb, line 30
def add_run
  @run_count += 1
  notify_listeners(CHANGED, self)
error_count() click to toggle source

Returns the number of errors this TestResult has recorded.

               # File test/unit/testresult.rb, line 75
def error_count
  return @errors.size
failure_count() click to toggle source

Returns the number of failures this TestResult has recorded.

               # File test/unit/testresult.rb, line 69
def failure_count
  return @failures.size
passed?() click to toggle source

Returns whether or not this TestResult represents successful completion.

               # File test/unit/testresult.rb, line 63
def passed?
  return @failures.empty? && @errors.empty?
to_s() click to toggle source

Returns a string contain the recorded runs, assertions, failures and errors in this TestResult.

               # File test/unit/testresult.rb, line 57
def to_s
  "#{run_count} tests, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors"

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.