Example 6-10. examples/intro/Test/MyTest.pm
package Test::MyTest;
use strict;
use warnings;
use base 'Exporter';
our @EXPORT_OK = qw(my_test);
use Test::Builder;
my $Test = Test::Builder->new;
sub my_test {
my ($x, $op, $y, $expected) = @_;
my $result;
if ($op eq '+') {
$result = $x + $y;
} else {
die "Not yet implemented";
}
$Test->is_num($result, $expected);
}
1;
Test modules created using Test::Builder all work nicely together. Among other things, they don't get confused with the counting of the tests.
Test::Simple, Test::More, Test::Exception, Test::Differences all use Test::Builder as a back-end.
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| Create a test module | Up | Number of tests |