in reply to Tests in a module/package?

My normal approach for handling this case is to make a lib directory under t directory for test library code. I can then use FindBin to add that directory to any test files that need it. I'm not sure where I got this idea. (I'm pretty sure it's not mine.)

This allows me to keep testing-specific utility code out of t/ but close by.

G. Wade

Replies are listed 'Best First'.
Re^2: Tests in a module/package?
by andreas1234567 (Vicar) on Mar 12, 2009 at 09:53 UTC
    Remember to write tests for the test library.

    Tests written using Test::Builder can easily be tested using Test::Builder::Tester. This is pretty good described in Perl Testing.

    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re^2: Tests in a module/package?
by doom (Deacon) on Mar 14, 2009 at 18:27 UTC
    Specifically, the usual idiom is to use FindBin with a "use lib" call, like this inside your *.t code:
    use FindBin qw( $Bin ); use lib "$Bin/lib"; use My::Special::Purpose::Test::Code qw( :all );
    This is the usual way to specify a module location relative to the script location.