I don't know if I've asked this on this list before or only on irc (I
can't find an earlier post on the subject, so I appologize if I'm asking
this a second time; I don't remember the answer).
I have a number of tests that create some object. The tests are not
unit tests, but I am using a unit test framework (RUNIT or Test::Unit)
to write the tests. This object is expensive (time-wise) to create, and
I would like to share the object between my tests. If I write this:
class MyTest < Test::Unit::TestCase
def setup
@f = Foo.new
end
def test_1
end
def test_2
end
end
then @f gets constructed twice; once for each instance of MyTest.
I'm currently doing this instead:
$f = Foo.new
class MyTest < Test::Unit::TestCase
def setup
@f = $f
end
def test_1
end
def test_2
end
end
but surely there has to be a better way! What can I do?
Paul