Run your tests from your editor. One of the nice things about Perl is the "tweak, run, tweak, run" development cycle. There's no separate compile phase to slow you down. However, you likely find yourself frequently writing tests and madly switching back and forth between the tests and the code. When you run the tests, you may exit the editor or type something like !perl -Ilib/ t/test_program.t in vi's command mode. This breaks the "tweak, run" rhythm. The HackPerl programmers don't like to slow things down. Instead, consider binding keys in your editor to the chicken-bone voodoo you use to run your test suite. Binding keysBy running the tests from within the editor, you no longer have to remember how to execute the tests or edit the editor. Just tweak and run. Add the following line to your .vimrc file to run the currently edited test file by typing ,t (comma, tee): map ,t <Esc>:!prove -vl %<CR> This technique uses the prove program to run your tests. prove is a handy little program distributed with and designed to run your tests through Test::Harness. The switches are v (vee), which tells prove to run in "verbose" mode and show all of the test output, and l (ell), which tells prove to add lib/ to @INC. If lib/ is not where you typically do your development, use the I switch to add a different path to @INC. map ,t <Esc>:!prove -Iwork/ -v %<CR> Seeing failuresIf it's a long test and you get a few failures, it can be difficult to see where the failures were. If that's the case, use ,T (comma capital tee) to pipe the results through your favorite pager. map ,T <Esc>:!prove -lv % \\| less<CR>
Managing pathsThese techniques do tend to require that you edit your tests in the "standard" way. If you have your tests organized in subdirectories, switching to the t/customer/ directory and editing save.t may cause problems when trying to tell prove which directories to use. If you habitually do this, don't tell prove which paths to add to @INC. map ,t <Esc>:!prove -v %<CR> Instead, have your tests add paths to @INC: use lib '../../lib'; That can get a bit clumsy and it can make it rather tough to reorganize your tests, but it works.
|