From: "Brian Schröder" Date: 2004-11-16T02:08:44+09:00 Subject: Re: Starter question on Test::Unit On Tue, 16 Nov 2004 00:36:25 +0900 Mohammad Khan wrote: > Hello, > > I am using Test::Unit for couple of days. > > I have a script something like this: > > class TestClass < Test::Unit::TestCase > > def setup > @foo = Foo.new > @run = Foo.run(@foo.key) > @rerun = Foo.rerun(@run.key) > end > > def test_run > assert_equal(@foo.key, @run.key) > end > > def test_rerun > assert_equal(@run.key, @rerun.key) > end > > end If you want to setup the variables once for the test case, you should use: class TestClass < Test::Unit::TestCase def initialize super @foo = Foo.new @run = Foo.run(@foo.key) @rerun = Foo.rerun(@run.key) end def test_run assert_equal(@foo.key, @run.key) end def test_rerun assert_equal(@run.key, @rerun.key) end end Would fill each variable only once. Regards, Brian -- Brian Schr�der http://www.brian-schroeder.de/