package MyModule; use strict; use warnings; sub add { my ($left, $right) = @_; return $left + $right; } 1; __END__ #### #!/usr/bin/perl use strict; use warnings; # we have 3 tests to run use Test::More tests => 3; # if you dont know how many tests # you have you can just replace: # tests => 3 # with: # "no_plan" # that way you dont have to count # your tests, although when you are # finished its best to put the plan back # in place. # test that we can require the module require_ok("MyModule.pm"); # it also has the added benefit of requiring # the actual module # test that the module has the function "add" available can_ok("MyModule", 'add'); # now test "add" works as expected cmp_ok(MyModule::add(1, 1), '==', 2, '... 1 added to 1 is 2'); #### prove test.t #### test....ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.15 cusr + 0.05 csys = 0.20 CPU)