> -----Original Message-----
> From: Paul Brannan [mailto:pbrannan / atdesk.com]=20
> Sent: Wednesday, March 05, 2008 11:24 AM
> To: ruby-core / ruby-lang.org
> Subject: Re: Adding startup and shutdown to Test::Unit
>=20
> On Wed, Mar 05, 2008 at 07:52:40AM +0900, Daniel Berger wrote:
> > Hm, something's goofy. I just noticed that instance=20
> variables aren't=20
> > surviving more than one test. Using the applied patches, I=20
> tried this:
>=20
> Test::Unit creates a new instance for every test case run. =20
> When I want the behavior you describe, I use class variables:
>=20
>   class MyTest < Test::Unit::TestCase
>     def setup
>       @@foo ||=3D 42
>     end
>   end

I can live with that for variables, but it won't cut it for other one
time operations. In some of my Ruby core tests, for example, I have
tests where I want to change to a particular directory, execute all the
tests, then change back to the original directory.
=20
> I'm not sure how I feel about your change, because a test=20
> suite can contain instance of multiple test case classes.

Before I looked at the source that's what I thought. That's not how it's
implemented, though. Look at self.suite in testcase.rb. Each *test*
within a given Test::Unit::TestCase itself becomes a
Test::Unit::TestCase object, which is then shoveled into a TestSuite's
@tests instance variable. I find the architecture strange, and difficult
to modify, but it seems to work. I'd have to pick Nathaniel's brain as
to why he did this.

> In that case, which startup/shutdown methods should get called and
when?

The startup and shutdown methods are unique to their test case, so one
doesn't interfere with another. I did a simple check where I had one
file require two other test files that each had a startup and shutdown
method and it works as expected.

In short, Test 1, startup, run tests, shutdown, Test 2, startup, run
tests, shutdown, etc.

Regards,

Dan


This communication is the property of Qwest and may contain confidential =
or
privileged information. Unauthorized use of this communication is =
strictly=20
prohibited and may be unlawful.  If you have received this communication =

in error, please immediately notify the sender by reply e-mail and =
destroy=20
all copies of the communication and any attachments.