I'm writing several tests using TAP::harness (and new to it) to run under Jenkins. In the process of writing these tests, I want to initially be able to run then from the command line and specify some additional parameters.
For example, one of the tests will install our project. This is a fairly lengthy process and I'd like to be able to skip this install test (along with the uninstall test later) in order to run the intervening tests faster.
To do this I set up the initial Perl test script to accept options (via GetOptions) and putting it into a global (our $noInstall). The print in the initial test script shows $noInstall is set, but when the test runs, $noInstall is undefined.
#!/usr/bin/perl
# unixIntegrationTest.pl
use strict;
use TAP::Harness::JUnit;
use Getopt::Long;
our $noInstall="";
GetOptions (
'n|no-install' => \$noInstall,
);
print("noInstall=$noInstall\n");
...
my @tests = (
[ 'unixInstall.t', 'Unix silent install' ],
[ 'unixUninstall.t', 'Unix silent uninstall' ],
);
$harness->runtests(@tests);
And in the test:
#unixInstall.t
use Test::More;
use silentInstall;
use Cwd;
use File::Path;
plan tests => 1;
print("noInstall=$noInstall\n");
...
The test output shows $noInstall as undefined.
I've tried all kinds of variations, like referencing $main::noInstall but to no avail. Any suggestions on how this should be done? Thanks.