class Minitest::Test
def self.i_suck_and_my_tests_are_order_dependent!
def self.i_suck_and_my_tests_are_order_dependent! class << self undef_method :test_order if method_defined? :test_order define_method :test_order do :alpha end end end
def self.make_my_diffs_pretty!
def self.make_my_diffs_pretty! require "pp" define_method :mu_pp, &:pretty_inspect end
def self.parallelize_me!
def self.parallelize_me! include Minitest::Parallel::Test extend Minitest::Parallel::Test::ClassMethods end
def self.runnable_methods
def self.runnable_methods methods = methods_matching(/^test_/) case self.test_order when :random, :parallel then max = methods.size methods.sort.sort_by { rand max } when :alpha, :sorted then methods.sort else raise "Unknown test_order: #{self.test_order.inspect}" end end
def self.test_order
def self.test_order :random end
def capture_exceptions # :nodoc:
def capture_exceptions # :nodoc: yield rescue *PASSTHROUGH_EXCEPTIONS raise rescue Assertion => e self.failures << e rescue Exception => e self.failures << UnexpectedError.new(sanitize_exception e) end
def class_name # :nodoc:
def class_name # :nodoc: self.class.name # for Minitest::Reportable end
def run
def run with_info_handler do time_it do capture_exceptions do before_setup; setup; after_setup self.send self.name end TEARDOWN_METHODS.each do |hook| capture_exceptions do self.send hook end end end end Result.from self # per contract end
def sanitize_exception e # :nodoc:
def sanitize_exception e # :nodoc: Marshal.dump e e rescue TypeError bt = e.backtrace e = RuntimeError.new "Wrapped undumpable exception for: #{e.class}: #{e.message}" e.set_backtrace bt e end
def with_info_handler &block # :nodoc:
def with_info_handler &block # :nodoc: t0 = Minitest.clock_time handler = lambda do warn "\nCurrent: %s#%s %.2fs" % [self.class, self.name, Minitest.clock_time - t0] end self.class.on_signal ::Minitest.info_signal, handler, &block end