[ACCEPTED]-How can I do unit testing in Perl?-testing
I'd add my vote to picking up Test::More
before going 9 any further in Perl testing. The Perl testing community is fairly 8 well united around the Test Anything Protocol, and you'll want 7 to play around with Test::More
to understand how it 6 works and how tools like prove
and Test::Harness::Archive
can help 5 automate and distribute testing.
If you want 4 to just "jump right in", I think 3 Test::Class
provides xTest facilities with a TAP backend. I 2 haven't used it at all (I'm a Test::More
person myself), but 1 it's very highly rated.
Test::More should offer you more bang for 1 your bucks once you get the hang of Test::Simple.
Judging by your comments on melaos answer, I'd 1 say Test::Class or Test::Unit is what you're looking for.
Simple test example:
#!/usr/bin/perl -w
use strict;
use warnings 'all';
use Test::More plan => 4; # or use Test::More 'no_plan';
use_ok('My::Module', 'Loaded My::Module');
ok( my $obj = My::Module->new(), 'Can create instance of My::Module');
ok( $obj->value('hello'), 'Set value to hello' );
is( $obj->value => 'hello', 'value is still hello');
0
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.