Using Test::Unit and running operations before and after a test suite

Hello all,

I am a very new Ruby user, trying to automated some tests.

I am using Test::Unit and would like to perform an operation once for
the setup of an entire suite of tests and another operation once for the
end/teardown of an entire suite of tests.
The setup and teardown methods will not work as those run after each
individual test method, and that is not acceptable for my purposes. I
only need these operations run once before and after the entire suite of
tests, not before and after each individual method.

Is there an easy way to accomplish this within Test::Unit?

Thanks!
Chris Pasillas

On Aug 20, 2010, at 14:50 , Christopher Pasillas wrote:

Hello all,

I am a very new Ruby user, trying to automated some tests.

I am using Test::Unit and would like to perform an operation once for the setup of an entire suite of tests and another operation once for the end/teardown of an entire suite of tests.
The setup and teardown methods will not work as those run after each individual test method, and that is not acceptable for my purposes. I only need these operations run once before and after the entire suite of tests, not before and after each individual method.

Is there an easy way to accomplish this within Test::Unit?

Unless you’re testing hardware or other physical processes, this is
often a false requirement. What are you trying to test and what do you
need to do before/after?

One quick and easy way (assuming you’re doing something like firing up a
DB) is to attach your tasks via rake. But that can be dirty, depending
on what you’re doing and how you need to do it.

IIRC, the gem version of test/unit has a bunch of enhancements to it and
I believe it includes a global setup/teardown. I dunno if it is per
testsuite or per run.