No, see, I want to establish a set_up/tear_down that are exectuted not once for each test, but a set_up that is run once before the first test is run, and a teat_down that is run once after the last test is run.
Test::Unit::Setup is a decorator for suites, not test cases, so you'll need to do something like this:
package My::TestCase;
use base qw(Test::Unit::TestCase);
use Test::Unit::TestSuite;
sub test_the_first {
my $self = shift;
$self->assert( 1, 'first' );
}
sub test_the_second {
my $self = shift;
$self->assert( 1, 'second' );
}
sub suite {
return MySuiteSetup->new(
Test::Unit::TestSuite->new( __PACKAGE__ )
);
}
package MySuiteSetup;
use base qw( Test::Unit::Setup );
sub set_up {
warn "before all tests\n";
}
sub tear_down {
warn "after all tests\n";
}
Our group is already pretty heavily invested in Test::Unit, but I can ask the other guys what they think of Test::Class
Just as a point of comparison, this would be how you would do it in Test::Class.
package My::Test;
use base qw( Test::Class );
use Test::More;
sub before :Test( startup ) {
warn "before all tests\n";
};
sub first :Test { pass };
sub second :Test { pass };
sub after :Test( shutdown ) {
warn "after all tests\n";
};
You might also be interested in PerlUnit@yahoogroups.com, a mailing list dedicated to Test::Unit. Traffic has been sparse though... |