Clean Functional Tests

* Posting on behalf of James Mead ( *

Sounds interesting. I've been doing my own monkey-patching recently ( and have noticed a couple of other people ( and doing similar things. It would be really good to get support for multiple setup/teardown methods into the Test::Unit library.


P.S. Apologies if this message is duplicated, I noticed that I sent to the old list address and am therefore re-sending.

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


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.


We use the same approach (method_added). I hope test/unit breaks its run method into more digestible chunks to make this unnecessary.