class MiniTest::Unit::TestCase
def self.inherited klass # :nodoc:
def self.inherited klass # :nodoc: @@test_suites[klass] = true end
def self.reset # :nodoc:
def self.reset # :nodoc: @@test_suites = {} end
def self.test_methods # :nodoc:
def self.test_methods # :nodoc: methods = public_instance_methods(true).grep(/^test/).map { |m| m.to_s } case self.test_order when :random 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 self.test_suites # :nodoc:
def self.test_suites # :nodoc: @@test_suites.keys.sort_by { |ts| ts.name } end
def initialize name # :nodoc:
def initialize name # :nodoc: @__name__ = name @passed = nil end
def passed?
def passed? @passed end
def run runner
def run runner trap 'INFO' do warn '%s#%s %.2fs' % [self.class, self.__name__, (Time.now - runner.start_time)] runner.status $stderr end if SUPPORTS_INFO_SIGNAL result = '.' begin @passed = nil self.setup self.__send__ self.__name__ @passed = true rescue *PASSTHROUGH_EXCEPTIONS raise rescue Exception => e @passed = false result = runner.puke(self.class, self.__name__, e) ensure begin self.teardown rescue *PASSTHROUGH_EXCEPTIONS raise rescue Exception => e result = runner.puke(self.class, self.__name__, e) end trap 'INFO', 'DEFAULT' if SUPPORTS_INFO_SIGNAL end result end
def setup; end
def setup; end
def teardown; end
def teardown; end