Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

53 views
Skip to first unread message

Michael Schuerig

unread,
Jun 10, 2005, 1:47:01 PM6/10/05
to

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

--
Michael Schuerig The more it stays the same,
mailto:mic...@schuerig.de The less it changes!
http://www.schuerig.de/michael/ --Spinal Tap, The Majesty of Rock

Nathaniel Talbott

unread,
Jul 9, 2005, 11:06:29 AM7/9/05
to
On Jun 10, 2005, at 13:50 , Michael Schuerig wrote:

> 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,


--
Nathaniel Talbott

<:((><

0 new messages