On Wed, Feb 28, 2018 at 05:10:26PM +0000, Alceu R. de Freitas Jr. via cpan-testers-discuss wrote: > Hello guys, > I'm in need to test some scripts inside one of my distributions and I'm bit > tired of writing boilerplate code for doing it. > > Maybe you could suggest something available on CPAN for that?
My approach is to have the script be mostly a wrapper around more easily-testable modules - the script just wrangles arguments and shows results. So the bulk of the logic can be tested in the usual fashion by testing the underlying modules. Then to test that it wrangles arguments and spits out the right results I use Capture::Tiny's "capture" sub thus: use Capture::Tiny qw(capture); use Config; my($stdout, $stderr, @result) = capture { system( $Config{perlpath}, (map { "-I$_" } (@INC)), qw( blib/script/... ... ) )}; and just make sure $stderr, $stdout, and @result (which contains the exit code reported by system()) are as expected. -- David Cantrell | Reality Engineer, Ministry of Information Repent through spending