From: Mohammad Khan Date: 2004-11-16T01:46:42+09:00 Subject: Re: Starter question on Test::Unit On Mon, 2004-11-15 at 11:33, Henrik Horneber wrote: > > > > I am confused about the '.' before the on second output 'in setup'. > > what does that '.' mean? > > > > Oh, that's just the ConsoleRunners' way of saying a test has succeeded. > > > Going back to my original example. > > If I want to use @foo, @run, @rerun (already initiated) in #test_rerun, > > what should I do? > > > > You could put both asserts in one test_function. There is no rule saying > you can only have one assertion per test function. Don't know if this is > feasible in your environment/setting though. > > For example: > > class TestClass < Test::Unit::TestCase > > def setup > @foo = Foo.new > @run = Foo.run(@foo.key) > @rerun = Foo.rerun(@run.key) > end > > def test_foo_runs > assert_equal(@foo.key, @run.key) > assert_equal(@run.key, @rerun.key) > end > end > Thanks again, Henrik. I have reason to keep two assert_equal in two #test_methods. Bottom line, I need @foo, @run and @rerun initiated once and I might have two or more methods like #test_run, #test_rerun, #test_rererun will use @foo, @run and @rerun. -- Mohammad > > > Or, is there any convention something like, #setup_run (would be used by > > only #test_run) or #setup_rerun (would be used by only #test_rerun) > > Not that I know of (which more or less doesn't mean anything). But since > only test_* methods get called from the test framework and TestClass > otherwise is a perfectly fine 'regular' class, you could write your own > setup_rerun method and call it from within your test function before > calling assert. But somehow I get the impression that this will result > in pretty bad code duplication or bloated test functions. > > IANATDE > ( I am not a test design expert ) > > :) > > Henrik