Created
November 30, 2009 18:33
-
-
Save alainravet/245622 to your computer and use it in GitHub Desktop.
test-unit setup_once/teardown_once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage : | |
# -------- | |
# require 'setup_once' | |
# class MyTest < Test::Unit::TestCase | |
# include SetupOnce | |
# | |
# def self.setup_once | |
# puts "doing one-time setup" | |
# end | |
# | |
# def self.teardown_once | |
# puts "doing one-time teardown" | |
# end | |
# | |
# ... | |
# end | |
module SetupOnce | |
def self.included(klass) | |
klass.extend(ClassMethods) | |
end | |
module ClassMethods | |
def setup_once; end | |
def teardown_once; end | |
def suite | |
mySuite = super | |
def mySuite.run(*args) | |
@name.to_class.setup_once | |
super(*args) | |
@name.to_class.teardown_once | |
end | |
return mySuite | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment