Class: Minitest::Result
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Runnable
|
|
Instance Chain:
self,
Reportable ,
Runnable
|
|
Inherits: |
Minitest::Runnable
|
Defined in: | lib/minitest.rb |
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 .from(a_test) you can be reasonably sure that the test result can be marshalled.
Constant Summary
Class Method Summary
-
.from(runnable)
Create a new test result from a
Runnable
instance.
Runnable
- Inherited
.methods_matching | Returns all instance methods matching the pattern |
.run | Responsible for running all runnable methods in a given class, each in its own instance. |
.run_one_method | Runs a single method and has the reporter record the result. |
.runnable_methods | Each subclass of |
.runnables | Returns all subclasses of |
.test_order | Defines the order to run tests (:random by default). |
.inherited, .new, .on_signal, .reset, .with_info_handler |
Instance Attribute Summary
-
#klass
rw
The class name of the test result.
-
#source_location
rw
The location of the test method.
Reportable
- Included
Runnable
- Inherited
#assertions | Number of assertions executed in this run. |
#failures | An assertion raised during the run, if any. |
#metadata | Metadata you attach to the test results that get sent to the reporter. |
#metadata= | Sets metadata, mainly used for .from. |
#metadata? | Returns true if metadata exists. |
#name | Name of the run. |
#name= | Set the name of the run. |
#passed? | Did this run pass? |
#skipped? | Was this run skipped? See |
#time | The time it took to run. |
Instance Method Summary
- #class_name Internal use only
- #to_s Internal use only
Reportable
- Included
#location | The location identifier of this test. |
#result_code | Returns “.”, “F”, or “E” based on the result of the run. |
#class_name |
Runnable
- Inherited
#result_code | Returns a single character string to print based on the result of the run. |
#run | Runs a single method. |
#failure, #marshal_dump, #marshal_load, #time_it |
Constructor Details
This class inherits a constructor from Minitest::Runnable
Class Method Details
.from(runnable)
Create a new test result from a Runnable
instance.
# File 'lib/minitest.rb', line 655
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. = o. if o. r.source_location = o.method(o.name).source_location rescue ["unknown", -1] r end
Instance Attribute Details
#klass (rw)
The class name of the test result.
# File 'lib/minitest.rb', line 645
attr_accessor :klass
#source_location (rw)
The location of the test method.
# File 'lib/minitest.rb', line 650
attr_accessor :source_location
Instance Method Details
#class_name
# File 'lib/minitest.rb', line 670
def class_name # :nodoc: self.klass # for Minitest::Reportable end
#to_s
# File 'lib/minitest.rb', line 674
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