module Minitest

Public Class Methods

__run(reporter, options) click to toggle source

Internal run method. Responsible for telling all Runnable sub-classes to run.

# File minitest-5.20.0/lib/minitest.rb, line 176
def self.__run reporter, options
  suites = Runnable.runnables.shuffle
  parallel, serial = suites.partition { |s| s.test_order == :parallel }

  # If we run the parallel tests before the serial tests, the parallel tests
  # could run in parallel with the serial tests. This would be bad because
  # the serial tests won't lock around Reporter#record. Run the serial tests
  # first, so that after they complete, the parallel tests will lock when
  # recording results. { |suite| reporter, options } + { |suite| reporter, options }
after_run(&block) click to toggle source

A simple hook allowing you to run a block of code after everything is done running. Eg:

Minitest.after_run { p $debugging_info }
# File minitest-5.20.0/lib/minitest.rb, line 97
def self.after_run &block
  @@after_run << block
autorun() click to toggle source

Registers Minitest to run at process exit

# File minitest-5.20.0/lib/minitest.rb, line 69
def self.autorun
  if Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
    Warning[:deprecated] = true

  at_exit {
    next if $! and not ($!.kind_of? SystemExit and $!.success?)

    exit_code = nil

    pid =
    at_exit {
      next if !Minitest.allow_fork && != pid
      exit exit_code || false

    exit_code = ARGV
  } unless @@installed_at_exit
  @@installed_at_exit = true
run(args = []) click to toggle source

This is the top-level run method. Everything starts from here. It tells each Runnable sub-class to run, and each of those are responsible for doing whatever they do.

The overall structure of a run looks like this:

    Minitest.__run(reporter, options)
      Runnable.runnables.each, options)
            self.run_one_method(self, runnable_method, reporter)
              Minitest.run_one_method(klass, runnable_method)
# File minitest-5.20.0/lib/minitest.rb, line 143
def args = []
  self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]

  options = process_args args

  Minitest.seed = options[:seed]
  srand Minitest.seed

  reporter =
  reporter <<[:io], options)
  reporter <<[:io], options)

  self.reporter = reporter # this makes it available to plugins
  self.init_plugins options
  self.reporter = nil # runnables shouldn't depend on the reporter, ever

  self.parallel_executor.start if parallel_executor.respond_to?(:start)
    __run reporter, options
  rescue Interrupt
    warn "Interrupted. Exiting..."


Public Instance Methods

backtrace_filter() click to toggle source

Filter object for backtraces.

# File minitest-5.20.0/lib/minitest.rb, line 43
cattr_accessor :backtrace_filter
extensions() click to toggle source

Names of known extension plugins.

# File minitest-5.20.0/lib/minitest.rb, line 55
cattr_accessor :extensions
info_signal() click to toggle source

The signal to use for dumping information to STDERR. Defaults to “INFO”.

# File minitest-5.20.0/lib/minitest.rb, line 60
cattr_accessor :info_signal
parallel_executor() click to toggle source

Parallel test executor

# File minitest-5.20.0/lib/minitest.rb, line 33
cattr_accessor :parallel_executor
reporter() click to toggle source

Reporter object to be used for all runs.

NOTE: This accessor is only available during setup, not during runs.

# File minitest-5.20.0/lib/minitest.rb, line 50
cattr_accessor :reporter
seed() click to toggle source

The random seed used for this run. This is used to srand at the start of the run and between each

Set via after processing args.

# File minitest-5.20.0/lib/minitest.rb, line 28
cattr_accessor :seed