Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Refactoring Perl 1 - Extract Method

by doom (Deacon)
on Jun 24, 2007 at 04:50 UTC ( #623040=note: print w/replies, xml ) Need Help??

in reply to Refactoring Perl #1 - Extract Method

Test::Output is very useful to testing code that generates STDOUT or STDERR as this code does.
I've been getting into Test::Trap of late, myself, which I think I've seen mentioned here. It has a pretty simple interface, and you can use it to trap errors as well.

I highly recommend Ian Langworth and chromatic's Perl Testing, A Developer's Notebook if you're not comfortable with writing and maintaining tests.

I like that book quite a bit, but what I would say is that if you're not into writing tests yet, you should look at the documentation for Test::More. There's no end of little tricks to writing tests (as in any kind of programming) but there's plenty of material to get started with right there in "Test::More" [1].

I have this fear that at some point the standard practice for testing perl is going to involve frameworks so elaborate that writing tests is going to turn into a sub-specialty that people are going to be afraid to get involved with...

[1] I have one complaint about the "Test::More" docs though: it's long since time they should stop directing newbies to "Test::Simple" first... "Test::More" is clearly the new standard.

Replies are listed 'Best First'.
Re^2: Refactoring Perl 1 - Extract Method
by agianni (Hermit) on Jun 25, 2007 at 15:09 UTC

    I think it's important for developers to figure out what testing scheme works well given the context of the tests they are writing. I use Test::Class for much of my testing these days because I'm working on large projects and T::C helps me keep things organized. But for small projects I still just use Test::More by itself to keep things simple. I will actually include examples of using Test::Class in later writeups. It's actually really easy an intuitive to use and allows for the use of T::M functionality within a XUnit framework.

    perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://623040]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2017-09-23 22:42 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (273 votes). Check out past polls.