From: Daniel Berger Date: 2009-05-14T22:45:24+09:00 Subject: Re: How can I use the "test/unit" > -----Original Message----- > From: artoxvw@gmail.com [mailto:artoxvw@gmail.com] > Sent: Thursday, May 14, 2009 7:17 AM > To: ruby-talk ML > Subject: How can I use the "test/unit" > > when I run the following code > > require 'test/unit' > class TC_Pram < Test::Unit::TestCase > def initialize(name) > @name=name > end > def test_array > puts assert_equal(2,@name[2]) > end > end > tc=TC_Pram.new("wang") > tc.test_array You don't want to use initialize. You want to use setup. class TC_Pram < Test::Unit::TestCase def setup @name = 'wang' end def test_array assert_equal(2, @name[2]) end end You don't need to instantiate an instance of TC_Pram. Just run the file. Regards, Dan