project/lib/Foo/Bar/Baz.pm project/lib/Foo.pm project/t/test1.t $ cat t/test1.t use lib './lib'; use strict; my $error; BEGIN { use vars qw($TESTCOUNT); use Test; # so we actually do some more stuff # here to load the Test module # since we distribute it with our package # in case the user doesn't have it $TESTCOUNT = 3; plan tests => $TESTCOUNT; # do some other testing eval { Some::module::Needed; }; if( $@ ) { $error =1 } } END { # if we exit prematurely in the test the testcount # will still be okay (assuming we want to bail # when some module isn't installed or # or the network is unavailable, etc. foreach ( $Test::ntest..$TESTCOUN) { skip("unable to run all the tests",1); } } if( $error ) { exit(0) } use Foo; use Foo::Bar::Baz; my $foo = new Foo(-id => '10'); ok($foo); ok($foo->id, '10); my $baz = new Foo::Bar::Baz(-magicword => 'peanutbuttersandwiches'); ok($base->magic, 'peanutbuttersandwiches'); $ perl -I. -w t/test1.t 1..3 ok 1 ok 2 ok 3