NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Test::More (Score:2)
Have you considered using Test::More? It has much more useful testing facilities and it allows you to name tests, which can give you very descriptive testing information. Further, if a test fails, it often provides very useful diagnostic information such as telling you what value you were expecting in $foo and what value $foo actually received. Here's a sample from some tests of a "People" object that I have.
#
# testing is_senior_contact()
#
$sql = <<"END_SQL";
SELECT people_id, category_id
FROM people_category
WHERE people_id = (SELECT min(people_id) FROM people_category)
END_SQL
$data = $db->_arrayref( $sql );
my ( $test_person, $test_category ) = @$data;
can_ok( $people->[0], 'is_senior_contact' );
$person = Foo::People->new( $test_person );
undef $data;
$data = $person->is_senior_contact( $test_category );
ok( $data, '... and a senior contact should return true' );
$data = $person->is_senior_contact( 0 );
ok( ! $data, '... and return false if they\'re not a senior contact' );
And this outputs:
ok 16 - Foo::People->can('is_senior_contact') ... and a senior contact should return true ... and return false if they're not a senior contact
ok 17 -
ok 18 -
If one of those tests fails, I find out instantly what test failed and why. This is a significant improvement over Test.pm.
Reply to This