Hi, In <03af6afa-9ba0-4124-bc2b-185f907c24f7 / a5g2000pre.googlegroups.com> "Re: Test::Unit - same test, different "args"" on Wed, 25 Mar 2009 04:51:52 +0900, "Luke St.Clair" <secureboot / gmail.com> wrote: > On Mar 23, 3:02 ¨Âí¬ ÂòéáÃáîäìå¼â®ãáîä®®®Àðïâïø®ãïí÷òïôåº >> Luke St.Clair wrote: >> > Is there some way to: >> > 1) set a global variable in the "parent" test suite that the children >> > see? ¨Âååíó ìéëå ôèáîó÷åò ôï ôèéó éó îï >> >> Shoulda sits on top of Test::Unit and may be helpful. Something like> this: >> >> class MyTest < Test::Unit::TestCase >> context "top level" do >> setup do >> @stuff = ... >> end >> >> should "test something at top level" do >> assert_equal 123, @stuff.size >> end >> >> context "inner level" do >> setup do >> @more_stuff = ... >> end >> >> should "test more" do >> assert_equal @stuff.size, @more_stuff.size >> end >> end >> end >> end > > This seems incredibly useful - unfortunately, I can't use shoulda. Test::Unit 2.x also supports that usage with natural Ruby syntax: # From http://test-unit.rubyforge.org/svn/trunk/sample/test_user.rb class UserTest < Test::Unit::TestCase def setup @user = "me" end def test_full_name assert_equal("me", @user) end class ProfileTest < UserTest setup def setup_profile @user += ": profile" end def test_has_profile assert_match(/: profile/, @user) end end end Thanks, -- kou