| Class | Test::Unit::TestResult |
| In: |
lib/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.
| CHANGED | = | "CHANGED" |
| FAULT | = | "FAULT" |
| assertion_count | [R] | |
| run_count | [R] |
Constructs a new, empty TestResult.
# File lib/test/unit/testresult.rb, line 24
24: def initialize
25: @run_count, @assertion_count = 0, 0
26: @failures, @errors = Array.new, Array.new
27: end
Records an individual assertion.
# File lib/test/unit/testresult.rb, line 50
50: def add_assertion
51: @assertion_count += 1
52: notify_listeners(CHANGED, self)
53: end
Records a Test::Unit::Error.
# File lib/test/unit/testresult.rb, line 43
43: def add_error(error)
44: @errors << error
45: notify_listeners(FAULT, error)
46: notify_listeners(CHANGED, self)
47: end
Records a Test::Unit::Failure.
# File lib/test/unit/testresult.rb, line 36
36: def add_failure(failure)
37: @failures << failure
38: notify_listeners(FAULT, failure)
39: notify_listeners(CHANGED, self)
40: end
Records a test run.
# File lib/test/unit/testresult.rb, line 30
30: def add_run
31: @run_count += 1
32: notify_listeners(CHANGED, self)
33: end
Returns the number of errors this TestResult has recorded.
# File lib/test/unit/testresult.rb, line 75
75: def error_count
76: return @errors.size
77: end
Returns the number of failures this TestResult has recorded.
# File lib/test/unit/testresult.rb, line 69
69: def failure_count
70: return @failures.size
71: end
Returns whether or not this TestResult represents successful completion.
# File lib/test/unit/testresult.rb, line 63
63: def passed?
64: return @failures.empty? && @errors.empty?
65: end
Returns a string contain the recorded runs, assertions, failures and errors in this TestResult.
# File lib/test/unit/testresult.rb, line 57
57: def to_s
58: "#{run_count} tests, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors"
59: end