in reply to Better arranging Test Suite
I often use a data-driven approach in such situations:
You have three parameters for each program:
One of 2. and 3. seems superfluous - either you have a literal match or a regex, but it's unlikely you need both. But that's a different problem.
My approach is to store all three items in a simple ASCII table and let the test driver run over that table:
use strict; use Test::More; use Test::Cmd; my @tests = map { split /\|/, $_, 3 } <DATA>; close DATA; plan tests => @tests * 3; for (@tests) { my ($prog,$stdout,$stdout_re) = @$_; my $cmd = Test::Cmd->new( prog => $prog ); is $cmd->run, 0, ">>$prog<< ran okay"; is $cmd->stdout, $stdout, 'Output is OK'; like $cmd->stdout, qr/$stdout_re/, 'Found expected output'; }; __DATA__ /bin/uname|Linux|Linux /bin/uname -n|Desktop1|Desktop
Update: andreas1234567 spotted a bug in the argument order to split, fixed
|
|---|