class Minitest::Result

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 you can be reasonably sure that the test result can be marshalled.



The class name of the test result.


The location of the test method.

Public Class Methods

from(runnable) click to toggle source

Create a new test result from a Runnable instance.

# File lib/minitest.rb, line 463
def self.from runnable
  o = runnable

  r =
  r.klass      =
  r.assertions = o.assertions
  r.failures   = o.failures.dup
  r.time       = o.time

  r.source_location = o.method( rescue ["unknown", -1]


Public Instance Methods

error?() click to toggle source

Did this run error?

# File lib/minitest.rb, line 480
def error?
  self.failures.any? { |f| UnexpectedError === f }
location() click to toggle source

The location identifier of this test.

# File lib/minitest.rb, line 487
def location
  loc = " [#{self.failure.location}]" unless passed? or error?
passed?() click to toggle source

Did this run pass?

Note: skipped runs are not considered passing, but they don't cause the process to exit non-zero.

# File lib/minitest.rb, line 498
def passed?
  not self.failure
result_code() click to toggle source

Returns “.”, “F”, or “E” based on the result of the run.

# File lib/minitest.rb, line 505
def result_code
  self.failure and self.failure.result_code or "."
skipped?() click to toggle source

Was this run skipped?

# File lib/minitest.rb, line 512
def skipped?
  self.failure and Skip === self.failure