Class: Test::Unit::TestResult
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | lib/test/unit/testresult.rb |
Overview
Constant Summary
-
CHANGED =
# File 'lib/test/unit/testresult.rb', line 35name + "::CHANGED"
-
FAULT =
# File 'lib/test/unit/testresult.rb', line 37name + "::FAULT"
-
FINISHED =
# File 'lib/test/unit/testresult.rb', line 34name + "::FINISHED"
-
PASS_ASSERTION =
# File 'lib/test/unit/testresult.rb', line 36name + "::PASS_ASSERTION"
Util::Observable
- Included
Class Method Summary
-
.new ⇒ TestResult
constructor
Constructs a new, empty
TestResult
.
Instance Attribute Summary
- #assertion_count readonly
- #faults readonly
- #pass_count readonly
-
#passed? ⇒ Boolean
readonly
Returns whether or not this
TestResult
represents successful completion. - #run_count readonly
- #stop_tag rw
TestResultNotificationSupport
- Included
TestResultOmissionSupport
- Included
TestResultPendingSupport
- Included
TestResultErrorSupport
- Included
TestResultFailureSupport
- Included
Instance Method Summary
-
#add_assertion
Records an individual assertion.
- #add_pass
-
#add_run(result = self)
Records a test run.
- #pass_percentage
-
#status
Returnes a string that shows result status.
- #stop
-
#summary
Returns a string contain the recorded runs, assertions, failures and errors in this
TestResult
. - #to_s
- #notify_changed private
- #notify_fault(fault) private
TestResultNotificationSupport
- Included
#add_notification | Records a |
#notification_count | Returns the number of notifications this |
#initialize_containers, #notification_summary |
TestResultOmissionSupport
- Included
#add_omission | Records a |
#omission_count | Returns the number of omissions this |
#initialize_containers, #omission_summary |
TestResultPendingSupport
- Included
#add_pending | Records a |
#pending_count | Returns the number of pendings this |
#initialize_containers, #pending_summary |
TestResultErrorSupport
- Included
#add_error | Records a |
#error_count | Returns the number of errors this |
#error_summary, #initialize_containers |
TestResultFailureSupport
- Included
#add_failure | Records a |
#failure_count | Returns the number of failures this |
#failure_summary, #initialize_containers |
NullResultContainerInitializer
- Included
Util::Observable
- Included
#add_listener | Adds the passed proc as a listener on the channel indicated by channel_name. |
#notify_listeners | Calls all the procs registered on the channel indicated by channel_name. |
#remove_listener | Removes the listener indicated by listener_key from the channel indicated by channel_name. |
#channels |
Constructor Details
.new ⇒ TestResult
Constructs a new, empty TestResult
.
# File 'lib/test/unit/testresult.rb', line 44
def initialize @run_count, @pass_count, @assertion_count = 0, 0, 0 @summary_generators = [] @problem_checkers = [] @faults = [] @stop_tag = nil initialize_containers end
Instance Attribute Details
#assertion_count (readonly)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 39
attr_reader :run_count, :pass_count, :assertion_count, :faults
#faults (readonly)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 39
attr_reader :run_count, :pass_count, :assertion_count, :faults
#pass_count (readonly)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 39
attr_reader :run_count, :pass_count, :assertion_count, :faults
#passed? ⇒ Boolean
(readonly)
Returns whether or not this TestResult
represents successful completion.
# File 'lib/test/unit/testresult.rb', line 108
def passed? @problem_checkers.all? {|checker| not __send__(checker)} end
#run_count (readonly)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 39
attr_reader :run_count, :pass_count, :assertion_count, :faults
#stop_tag (rw)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 41
attr_accessor :stop_tag
Instance Method Details
#add_assertion
Records an individual assertion.
# File 'lib/test/unit/testresult.rb', line 65
def add_assertion @assertion_count += 1 notify_listeners(PASS_ASSERTION, self) notify_changed end
#add_pass
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 60
def add_pass @pass_count += 1 end
#add_run(result = self)
Records a test run.
# File 'lib/test/unit/testresult.rb', line 54
def add_run(result=self) @run_count += 1 notify_listeners(FINISHED, result) notify_changed end
#notify_changed (private)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 122
def notify_changed notify_listeners(CHANGED, self) end
#notify_fault(fault) (private)
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 126
def notify_fault(fault) @faults << fault notify_listeners(FAULT, fault) end
#pass_percentage
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 112
def pass_percentage n_tests = @run_count - omission_count if n_tests.zero? 0 else 100.0 * (@pass_count / n_tests.to_f) end end
#status
Returnes a string that shows result status.
# File 'lib/test/unit/testresult.rb', line 80
def status if passed? if pending_count > 0 "pending" elsif omission_count > 0 "omission" elsif notification_count > 0 "notification" else "pass" end elsif error_count > 0 "error" elsif failure_count > 0 "failure" end end
#stop
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 98
def stop throw @stop_tag end
#summary
Returns a string contain the recorded runs, assertions, failures and errors in this TestResult
.
# File 'lib/test/unit/testresult.rb', line 73
def summary ["#{run_count} tests", "#{assertion_count} assertions", *@summary_generators.collect {|generator| __send__(generator)}].join(", ") end
#to_s
[ GitHub ]# File 'lib/test/unit/testresult.rb', line 102
def to_s summary end