Dr Bean wrote:
I've gotten comfortable with Test::More conventions, but it's
difficult in my editor to really quickly create lots of tests.
is($o->index('You'), 1, 'objects index 1');
isnt($o->index(1), 1, 'objects index 2');
isnt($o->index(2), 2, 'objects index 2');
is($o->index($t), 3, 'objects index 3');
I frequently wind up putting my repetitive cases in a data structure and
then looping over that rather than writing cases individually. E.g.
use Test::More;
my @cases = (
[ 'You' ,1 ],
[ $t ,3 ],
);
plan tests => @is_cases;
for my $c ( @cases ) {
is( $o->index( $c->[0] ), $c->[1], "objects index $c->[1]" );
}
Sometimes I use hashes rather than arrays, particularly if the examples
or test loops get long. Likewise, I often include the test label in the
case as well.
Test::Base makes that all a bit more automatic, but I prefer to avoid it
so that simple little modules I write don't suddenly inherit a big
build_requires dependency chain.
Regards,
David Golden