From: Wilson Bilkovich Date: 2007-09-27T11:18:32+09:00 Subject: Re: Syntax for .new ? On 9/26/07, Larry Fast wrote: > Thank you all. This version was all I needed: > Object.const_get(klass) > I'm receiving only the child-class name with none of it's parentage. > > But now I'm trying to curious about how Test::Unit does this job. My > first kick at this problem was to find out how it was done there. I > still haven't found anything that looks like Object instantiation in the > Test::Unit code. > Test::Unit uses ObjectSpace *shiver* to do its work, at the moment. In my opinion, a better way to do it would be: class Test::Unit::TestCase def self.inherited(subclass) @test_cases ||= [] @test_cases << subclass end def self.test_cases @test_cases || [] end end That way it would collect up a list of classes as they were defined, and then: at_exit do Test::Unit::TestCase.test_cases.each {|tc| tc.run_thyself } end