Class: Minitest::Result
Overview
This represents a test result in a clean way that can be marshalled over a wire. Tests can do anything they want to the test instance and can create conditions that cause Marshal.dump to blow up. By using Result.from(a_test) you can be reasonably sure that the test result can be marshalled.
Direct Known Subclasses
Constant Summary
Constants inherited from Runnable
Instance Attribute Summary collapse
-
#klass ⇒ Object
The class name of the test result.
-
#source_location ⇒ Object
The location of the test method.
Attributes inherited from Runnable
Class Method Summary collapse
-
.from(runnable) ⇒ Object
Create a new test result from a Runnable instance.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Did this run error?.
-
#location ⇒ Object
The location identifier of this test.
-
#passed? ⇒ Boolean
Did this run pass?.
-
#result_code ⇒ Object
Returns “.”, “F”, or “E” based on the result of the run.
-
#skipped? ⇒ Boolean
Was this run skipped?.
-
#to_s ⇒ Object
:nodoc:.
Methods inherited from Runnable
#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, reset, run, #run, run_one_method, runnable_methods, runnables, #time_it, with_info_handler
Constructor Details
This class inherits a constructor from Minitest::Runnable
Instance Attribute Details
#klass ⇒ Object
The class name of the test result.
453 454 455 |
# File 'lib/minitest.rb', line 453 def klass @klass end |
#source_location ⇒ Object
The location of the test method.
458 459 460 |
# File 'lib/minitest.rb', line 458 def source_location @source_location end |
Class Method Details
.from(runnable) ⇒ Object
Create a new test result from a Runnable instance.
463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/minitest.rb', line 463 def self.from runnable o = runnable r = self.new o.name r.klass = o.class.name r.assertions = o.assertions r.failures = o.failures.dup r.time = o.time r.source_location = o.method(o.name).source_location rescue ["unknown", -1] r end |
Instance Method Details
#error? ⇒ Boolean
Did this run error?
480 481 482 |
# File 'lib/minitest.rb', line 480 def error? self.failures.any? { |f| UnexpectedError === f } end |
#location ⇒ Object
The location identifier of this test.
487 488 489 490 |
# File 'lib/minitest.rb', line 487 def location loc = " [#{self.failure.location}]" unless passed? or error? "#{self.klass}##{self.name}#{loc}" end |
#passed? ⇒ Boolean
Did this run pass?
Note: skipped runs are not considered passing, but they don’t cause the process to exit non-zero.
498 499 500 |
# File 'lib/minitest.rb', line 498 def passed? not self.failure end |
#result_code ⇒ Object
Returns “.”, “F”, or “E” based on the result of the run.
505 506 507 |
# File 'lib/minitest.rb', line 505 def result_code self.failure and self.failure.result_code or "." end |
#skipped? ⇒ Boolean
Was this run skipped?
512 513 514 |
# File 'lib/minitest.rb', line 512 def skipped? self.failure and Skip === self.failure end |
#to_s ⇒ Object
:nodoc:
516 517 518 519 520 521 522 |
# File 'lib/minitest.rb', line 516 def to_s # :nodoc: return location if passed? and not skipped? failures.map { |failure| "#{failure.result_label}:\n#{self.location}:\n#{failure.}\n" }.join "\n" end |