Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Testing Perl files rather than modules

by Erez (Curate)
on Sep 17, 2008 at 07:48 UTC ( #711910=note: print w/ replies, xml ) Need Help??


in reply to Testing Perl files rather than modules

Perl doesn't have "include", but it has "use" and "require"

#!/usr/bin/perl #script.pl use strict; use warnings; sub hello { return "Hello, World!\n" } 1; #!/usr/bin/perl #test.t use strict; use warnings; use Test::More tests => 2; require_ok("script.pl"); #tests 'require "script.pl" is(hello(), "Hello, World!\n", 'hello() should return "Hello, World!"'

Stop saying 'script'. Stop saying 'line-noise'.
We have nothing to lose but our metaphors.


Comment on Re: Testing Perl files rather than modules
Download Code
Re^2: Testing Perl files rather than modules
by Erez (Curate) on Sep 17, 2008 at 07:55 UTC

      I too have had a recent epiphany "must get serious about testing". So I bought this book too.</p.

      And I was left with "... but how do I get "there" from "here"??. Because it does tend to start with

      use YourMod::YourStuff;

      ... which is not very handy if you are not in a modularized position to begin with.

      I got a great tip from gabszab which suited my current situation (big monolithic CGI script), which was 'invoke the whole thing from your test and use cmp_ok ', but that's another subject (although it might help in our situation?).

      This signature will be ready by Christmas

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-12-20 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls