Of course, you can test the scripts with Test :: More . This is simply harder because most scripts need to be run as a separate process from which you extract the output, and then check it for the expected output.
This is why modulinos (see chapter 17 in: brian d foy , Mastering Perl , second edition, O'Reilly, 2014). Modulino is a script that can also be used as a module. This makes testing easier, since you can load a module into your test script and then test its functions, just like a regular module.
A key feature of modulino is the following:
#! /usr/bin/perl package App::MyName;
The function should not be called run
; you can use main
if you are a C programmer. You usually also have additional routines that run
calls if necessary.
Then your test scripts can use require "path/to/script"
to load your module and implement its functions. Since many scripts include writing output, and it is often easier to print as you go instead of print sub_that_returns_big_string()
, you may find Test :: Output useful.
source share