Test::Unit: setup & teardown around an entire suite?

M

Michael Schuerig

Is there a way to wrap setup and teardown methods around an entire
suite? I haven't seen explicit methods for this purpose, but maybe
there's an idiomatic way to achieve the same result.

Michael
 
N

Nathaniel Talbott

Is there a way to wrap setup and teardown methods around an entire
suite? I haven't seen explicit methods for this purpose, but maybe
there's an idiomatic way to achieve the same result.

This is late, but here's something that will work:

require 'test/unit'

class T < Test::Unit::TestCase
def setup
p 'setup'
end
def teardown
p 'teardown'
end
def test1
p 'test1'
end
def test2
p 'test2'
end
def self.suite
s = super
def s.setup
p 'suite_setup'
end
def s.teardown
p 'suite_teardown'
end
def s.run(*args)
setup
super
teardown
end
s
end
end

I do plan on providing a better way to do that, but for now we can
just lean on the extreme flexibility of Ruby.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top