endy_tj
5/6/2006 2:10:00 AM
Hello all,
In Test::Unit, setup and teardown run before and after each test
method, but currently there are no hooks that run before and after each
test class (it's in the to-do list according to Nathaniel Talbott).
In the mean time, how can I achieve the same result using a workaround?
Anybody tried this before?
Actually it's a Rails unit test. I want to prepare the rows at the
beginning of the test class, run test methods with
use_transactional_fixtures set to true (rollback after each test
method), then cleanup the rows at the end of the test class.
Rails Fixture is not enough because I want to prepare other tables too,
not just the current ActiveRecord table.
Preparing the db before running the tests is also not flexible enough
because I want to expose my models to various row conditions: when
table is empty, when table has one row, etc. My plan is to have a test
class for an empty table, a test class for table with one row, etc.
Can I just put db prep in the same file with test class definition,
before class definition, and db cleanup after class definition? Does it
run sequentially from top to bottom?
--
Endy