Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Tests in a module/package?

by gwadej (Chaplain)
on Mar 11, 2009 at 20:15 UTC ( [id://750011]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://750011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-24 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found