Chris_Roos
(Chris Roos)
1
* Posting on behalf of James Mead (jamesmead44@gmail.com) *
Sounds interesting. I've been doing my own monkey-patching recently
(http://mocha.rubyforge.org/classes/MultipleSetupAndTeardown.html) and
have noticed a couple of other people
(http://www.agilewebdevelopment.com/plugins/testcase_setup_and_teardown_with_blocks
and http://mabs29.googlecode.com/svn/trunk/plugins/active_test/lib/active_test/base.rb)
doing similar things. It would be really good to get support for
multiple setup/teardown methods into the Test::Unit library.
James.
P.S. Apologies if this message is duplicated, I noticed that I sent to
the old list address and am therefore re-sending.
bitsweat
(Jeremy Daer)
2
I’d like class methods to declare setup/teardown behavior:
setup :load_fixtures, :begin_transaction
teardown :rollback_transaction
same with teardown
def self.setup(*methods, &block)
setup_methods.concat(methods)
setup_methods << block if block_given?
end
unfortunately difficult to override, have to replace wholesale
def run
…
begin
#instead of setup
call_setup_methods
…
ensure
begin
#instead of teardown
call_teardown_methods
…
end
jeremy
Jonathan5
(Jonathan)
3
My plugin allows you to do that. It’s a huge hack, but it works for me! As far as I know it is completely backwards compatible.
http://svn.viney.net.nz/things/rails/plugins/testcase_setup_and_teardown_with_blocks
-Jonathan.
bitsweat
(Jeremy Daer)
4
We use the same approach (method_added). I hope test/unit breaks its run method into more digestible chunks to make this unnecessary.
jeremy