In Files

  • minitest/unit.rb

MiniTest::Unit::LifecycleHooks

Provides before/after hooks for setup and teardown. These are meant for library writers, NOT for regular test authors. See before_setup for an example.

Public Instance Methods

after_setup() click to toggle source

Runs before every test, after setup. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.

See before_setup for an example.

 
               # File minitest/unit.rb, line 1129
def after_setup; end
            
after_teardown() click to toggle source

Runs after every test, after teardown. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.

See before_setup for an example.

 
               # File minitest/unit.rb, line 1182
def after_teardown; end
            
before_setup() click to toggle source

Runs before every test, before setup. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.

As a simplistic example:

module MyMinitestPlugin
  def before_setup
    super
    # ... stuff to do before setup is run
  end

  def after_setup
    # ... stuff to do after setup is run
    super
  end

  def before_teardown
    super
    # ... stuff to do before teardown is run
  end

  def after_teardown
    # ... stuff to do after teardown is run
    super
  end
end

class MiniTest::Unit::TestCase
  include MyMinitestPlugin
end
 
               # File minitest/unit.rb, line 1164
def before_setup; end
            
before_teardown() click to toggle source

Runs after every test, before teardown. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.

See before_setup for an example.

 
               # File minitest/unit.rb, line 1173
def before_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