Class: Test::Unit::TestResult
- Inherits:
-
Object
- Object
- Test::Unit::TestResult
- Includes:
- NullResultContainerInitializer, TestResultErrorSupport, TestResultFailureSupport, TestResultNotificationSupport, TestResultOmissionSupport, TestResultPendingSupport, Util::Observable
- Defined in:
- lib/test/unit/testresult.rb
Overview
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.
Constant Summary collapse
- CHANGED =
"CHANGED"
- FAULT =
"FAULT"
Constants included from Util::Observable
Instance Attribute Summary collapse
-
#assertion_count ⇒ Object
readonly
Returns the value of attribute assertion_count.
-
#faults ⇒ Object
readonly
Returns the value of attribute faults.
-
#run_count ⇒ Object
readonly
Returns the value of attribute run_count.
Attributes included from TestResultNotificationSupport
Attributes included from TestResultOmissionSupport
Attributes included from TestResultPendingSupport
Attributes included from TestResultErrorSupport
Attributes included from TestResultFailureSupport
Instance Method Summary collapse
-
#add_assertion ⇒ Object
Records an individual assertion.
-
#add_run ⇒ Object
Records a test run.
-
#initialize ⇒ TestResult
constructor
Constructs a new, empty TestResult.
-
#passed? ⇒ Boolean
Returns whether or not this TestResult represents successful completion.
-
#summary ⇒ Object
Returns a string contain the recorded runs, assertions, failures and errors in this TestResult.
- #to_s ⇒ Object
Methods included from TestResultNotificationSupport
#add_notification, #notification_count
Methods included from TestResultOmissionSupport
#add_omission, #omission_count
Methods included from TestResultPendingSupport
Methods included from TestResultErrorSupport
#add_error, #error_count, #error_occurred?
Methods included from TestResultFailureSupport
#add_failure, #failure_count, #failure_occurred?
Methods included from Util::Observable
#add_listener, #notify_listeners, #remove_listener
Constructor Details
#initialize ⇒ TestResult
Constructs a new, empty TestResult.
40 41 42 43 44 45 46 |
# File 'lib/test/unit/testresult.rb', line 40 def initialize @run_count, @assertion_count = 0, 0 @summary_generators = [] @problem_checkers = [] @faults = [] initialize_containers end |
Instance Attribute Details
#assertion_count ⇒ Object (readonly)
Returns the value of attribute assertion_count.
37 38 39 |
# File 'lib/test/unit/testresult.rb', line 37 def assertion_count @assertion_count end |
#faults ⇒ Object (readonly)
Returns the value of attribute faults.
37 38 39 |
# File 'lib/test/unit/testresult.rb', line 37 def faults @faults end |
#run_count ⇒ Object (readonly)
Returns the value of attribute run_count.
37 38 39 |
# File 'lib/test/unit/testresult.rb', line 37 def run_count @run_count end |
Instance Method Details
#add_assertion ⇒ Object
Records an individual assertion.
55 56 57 58 |
# File 'lib/test/unit/testresult.rb', line 55 def add_assertion @assertion_count += 1 notify_changed end |
#add_run ⇒ Object
Records a test run.
49 50 51 52 |
# File 'lib/test/unit/testresult.rb', line 49 def add_run @run_count += 1 notify_changed end |
#passed? ⇒ Boolean
Returns whether or not this TestResult represents successful completion.
74 75 76 |
# File 'lib/test/unit/testresult.rb', line 74 def passed? @problem_checkers.all? {|checker| not send(checker)} end |
#summary ⇒ Object
Returns a string contain the recorded runs, assertions, failures and errors in this TestResult.
62 63 64 65 66 |
# File 'lib/test/unit/testresult.rb', line 62 def summary ["#{run_count} tests", "#{assertion_count} assertions", *@summary_generators.collect {|generator| send(generator)}].join(", ") end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/test/unit/testresult.rb', line 68 def to_s summary end |