tags:

views:

241

answers:

1

What's the best way to have a setup run before every method in an entire test suite (not just one test class)?

Rspec allows you to define global before and after blocks. Is there a clean comparable way to do this in Test::Unit that doesn't involve mixing a module into each test class?

+2  A: 
Patrick Reagan
In this project it's necessary to clear some global memory caches, so that test cases don't pollute each other. I agree in general that this is a bit of a smell, but IMO it makes more sense here than requiring developers to remember to call a helper, and dealing with the sometime unpredictable consequences.I'm wondering if there's someway to avoid having to call super in each subclass that defines a setup. Does ActiveSupport::TestCase provide this feature with its setups/teardowns?
samg
I added to the original response - not sure if that solution gets you any closer.
Patrick Reagan