Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus