Class: Test::Unit::TestResult

Class | Test::Unit::TestResult
In: | test/unit/testresult.rb
Parent: | Object

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.

### Methods

add_assertion add_error add_failure add_run error_count failure_count new passed? to_s

### Included Modules

Util::Observable

### Constants

CHANGED | = | "CHANGED"
FAULT | = | "FAULT"

### Attributes

assertion_count | [R] |
run_count | [R] |

### Public Class methods

new()

Constructs a new, empty TestResult.

[Source]

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

### Public Instance methods

add_assertion()

Records an individual assertion.

[Source]

    # File test/unit/testresult.rb, line 49
          def add_assertion
            @assertion_count += 1
            notify_listeners(CHANGED, self)
          end

add_error(error)

Records a Test::Unit::Error.

[Source]

    # File test/unit/testresult.rb, line 42
          def add_error(error)
            @errors << error
            notify_listeners(FAULT, error)
            notify_listeners(CHANGED, self)
          end

add_failure(failure)

Records a Test::Unit::Failure.

[Source]

    # File test/unit/testresult.rb, line 35
          def add_failure(failure)
            @failures << failure
            notify_listeners(FAULT, failure)
            notify_listeners(CHANGED, self)
          end

add_run()

Records a test run.

[Source]

    # File test/unit/testresult.rb, line 29
          def add_run
            @run_count += 1
            notify_listeners(CHANGED, self)
          end

error_count()

Returns the number of errors this TestResult has recorded.

[Source]

    # File test/unit/testresult.rb, line 74
          def error_count
            return @errors.size
          end

failure_count()

Returns the number of failures this TestResult has recorded.

[Source]

    # File test/unit/testresult.rb, line 68
          def failure_count
            return @failures.size
          end

passed?()

Returns whether or not this TestResult represents successful completion.

[Source]

    # File test/unit/testresult.rb, line 62
          def passed?
            return @failures.empty? && @errors.empty?
          end

to_s()

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

[Source]

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

[Validate]