Hi,

At Sat, 21 Oct 2006 22:10:49 +0900,
Jay wrote in [ruby-core:09316]:
> Using the test class method also allows you to detect tests with  
> duplicate names and raise an error.  I believe this is far superior  
> to silently failing (where failing is defined as a test that I  
> expected to run was not run).

FYI: quoting from http://jarp.does.notwork.org/diary/200610b.html#200610111

  module Test::Unit
    def self.define(test_name = caller.first.sub(/ in `.*'\z/, ''), &block)
      Class.new(Test::Unit::TestCase) do
        class << self; attr_reader :name end
        @name = test_name.to_s
        class_eval(&block)
      end
    end
  end

  Test::Unit.define do
    def test_foo
      assert true
    end
  end

> class Test::Unit::TestCase
>    def self.test(name, &block)
>      test_name = :"test_#{name.gsub(' ','_')}"
       raise ArgumentError, "#{test_name} is already defined" if self.method_defined? test_name
>      define_method test_name, &block
>    end
> end

Mixing with your method, it would be possible like:

  Test::Unit.define do
    test "two plus two should equal four" do
      assert_equal 4, Math.plus(2,2)
    end
  end

-- 
Nobu Nakada