From: James Davis Date: 2003-10-10T01:19:03+09:00 Subject: Re: Test Unit help >Help is just a simple refactoring away. Since the test_xxx methods are >called by the framework, changing their signatures is a questionable >tactic (although one /would/ think that the default argument would >work). > >Basically you just need to break the code into separate functions and >then call those functions from the test methods. For example ... > >class TC_Work < Test::Unit::TestCase > def setup > @worker = Worker.new > end > > def test_do_some_work > check_some_work(@worker) > end > > def check_some_work(w) > s = 'a' > i = 25 > assert_equal('abcdefghijklmnopqrstuvwxyz', w.do_some_work(s, i)) > end > >end Yes. Two important realizations here: 1) Assertions need not be placed in 'test_xxx' methods. 2) Refactor mercilessly! Thanks, - Jim Davis -