http://www.perlmonks.org?node_id=623040


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.