|XP is just a number|
Re: Test driven development and glue codeby xdg (Monsignor)
|on Oct 05, 2005 at 22:57 UTC||Need Help??|
First, you might want to look at How a script becomes a module. The general idea is to convert most of the functionality of a script into a module, and test that as you would a module.
In general, for testing scripts, you need to write a test file that you can run with prove. In testing scripts, I've found IPC::Run3 to be helpful for driving inputs and outputs in a platform independent way. E.g.
prove -v dummy.t produces:
There you go -- a basic script test. All you need to do is keep adding to the test script (or create new ones), run it with prove, and then add code until it works, and you're doing TDD for scripts.
For helpers to test specific behavior or to help you write your own tests of specific behaviors, you might want to look at:
You may need to write new test helpers for things like process killing, or user changes, but you can either build that up with Test::More (or even write new Test:: modules with Test::Builder and release them to CPAN for all to use.)
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.