In Files

  • minitest/unit.rb

Parent

Included Modules

MiniTest::Unit::TestCase

Subclass TestCase to create your own tests. Typically you'll want a TestCase subclass per implementation class.

Public Class Methods

test_order() click to toggle source

Defines test order and is subclassable. Defaults to :random but can be overridden to return :alpha if your tests are order dependent (read: weak).

 
               # File minitest/unit.rb, line 735
def self.test_order
  :random
end
            

Public Instance Methods

passed?() click to toggle source

Returns true if the test passed.

 
               # File minitest/unit.rb, line 760
def passed?
  @passed
end
            
run(runner) click to toggle source

Runs the tests reporting the status to runner

 
               # File minitest/unit.rb, line 684
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
            
setup() click to toggle source

Runs before every test. Use this to refactor test initialization.

 
               # File minitest/unit.rb, line 767
def setup; end
            
teardown() click to toggle source

Runs after every test. Use this to refactor test cleanup.

 
               # File minitest/unit.rb, line 772
def teardown; end