Hi,

At Wed, 4 Feb 2004 17:26:54 +0900,
Ian Macdonald wrote in [ruby-talk:91524]:
> In the example above, I have renamed the classes from their true names.
> Interestingly, I now note that I get the correct overriding behaviour if
> the subclass of TC_Foo has a name that alphabetically sorts earlier.
> 
> In other words, the code as shown above actually works, because TC_Bar
> (the subclass) sorts higher than TC_Foo (the superclass). If I change
> the name of the TC_Bar class to TC_Goo, however, TC_Foo#setup is no
> longer overridden by the method of the same name in the subclass.
> 
> This seems like an odd and arbitrary way to go about things. Is this the
> intention or some obscure side-effect of my trying to do something
> irrational?

Seems fine.

  $ cat test.rb
  class TC_Foo < Test::Unit::TestCase
    def setup
      puts "Foo#setup"
    end

    def test_method1
      assert_nothing_raised {puts "Foo#test_method1"}
    end

    def test_method2
      assert_nothing_raised {puts "Foo#test_method2"}
    end
  end

  class TC_Goo < TC_Foo
    def setup
      puts "Goo#setup"
    end

    def test_method1
      assert_nothing_raised {puts "Goo#test_method1"}
    end

    # TC_foo#method2 will get called for

  end
  $ testrb -vs test.rb
  Foo#setup
  Foo#test_method1
  Foo#setup
  Foo#test_method2
  Goo#setup
  Goo#test_method1
  Goo#setup
  Foo#test_method2

-- 
Nobu Nakada