On Nov 18, 2007, at 3:50 AM, nadim khemir wrote:
What are your thoughts, way of working that avoid the problems to
start with
I organize my test files using an approach similar to nUnit - I create
a bunch of subroutines that each do a few assertions, and that call
set_up() and tear_down().
In my foo.t file I might have:
#-------------------------------------------
use strict;
use warnings;
use Readonly;
use Test::More tests => 10;
Readonly my $CLASS_UNDER_TEST => Foo::Bar;
use_ok($CLASS_UNDER_TEST);
test_foo();
test_bar();
test_baz();
exit;
sub set_up {
my $object = Foo::Bar->new();
return $object;
}
sub tear_down {
my @things_to_destroy = @_;
foreach $thing (@things_to_destroy) {
undef $thing;
}
return 1;
}
sub test_foo {
my $foo = set_up();
# do some assertions using $foo
return tear_down($foo);
}
sub test_bar {
my $foo = set_up();
# do some assertions using $foo
return tear_down($foo);
}
sub test_baz {
my $foo = set_up();
# do some assertions using $foo
return tear_down($foo);
}
#----------------------------
-------------------------------------------------------
Matisse Enzer <[EMAIL PROTECTED]>
http://www.matisse.net/ - http://www.eigenstate.net/