On Wed, Apr 02, 2003 at 04:27:46AM +0900, Phil Tomson wrote:
> What if you make it a class variable instead?
> Something like:
> 
> class MyTest < Test::Unit::TestCase
>   @@f = Foo.new
>   
>   def test1
>   ... do stuff with @@f
>   end
> 
>   def test2
>   ... do stuff with @@f
>   end
> end

Then if I require the file with MyTest but I never run MyTest, I still
create Foo.  I instead do this:

  class MyTest < Test::Unit::TestCase
    @@setup_once = false
  
    def setup
      if not @@setup_once then
        @@f = Foo.new
        @@setup_once = true
      end
    end
  
    def test1
    end
  
    def test2
    end
  end

Still, I can't help but think there is a better way.

Paul