123456789_123456789_123456789_123456789_123456789_

Class: Minitest::Result

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Runnable
Instance Chain:
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

Runnable - Inherited

SIGNALS

Class Method Summary

Runnable - Inherited

.methods_matching

Returns all instance methods matching the pattern re.

.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 Runnable is responsible for overriding this method to return all runnable methods.

.runnables

Returns all subclasses of Runnable.

.inherited, .new, .on_signal, .reset, .with_info_handler

Instance Attribute Summary

Reportable - Included

#error?

Did this run error?

#passed?

Did this run pass?

#skipped?

Was this run skipped?

Runnable - Inherited

#assertions

Number of assertions executed in this run.

#failures

An assertion raised during the run, if any.

#name

Name of the run.

#name=

Set the name of the run.

#passed?

Did this run pass?

#skipped?

Was this run skipped? See #passed? for more information.

#time

The time it took to run.

Instance Method Summary

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.

[ GitHub ]

  
# File 'lib/minitest.rb', line 521

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 Attribute Details

#klass (rw)

The class name of the test result.

[ GitHub ]

  
# File 'lib/minitest.rb', line 511

attr_accessor :klass

#source_location (rw)

The location of the test method.

[ GitHub ]

  
# File 'lib/minitest.rb', line 516

attr_accessor :source_location

Instance Method Details

#class_name

This method is for internal use only.
[ GitHub ]

  
# File 'lib/minitest.rb', line 535

def class_name # :nodoc:
  self.klass # for Minitest::Reportable
end

#to_s

This method is for internal use only.
[ GitHub ]

  
# File 'lib/minitest.rb', line 539

def to_s # :nodoc:
  return location if passed? and not skipped?

  failures.map { |failure|
    "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
  }.join "\n"
end