[Bioperl-l] New testing base: BioperlTest.pm
Sendu Bala
bix at sendu.me.uk
Wed Jun 20 15:38:20 UTC 2007
In considering updating all the test scripts to take advantage of the
new network option, and/or reimplementing them in Test::More, I thought
now would be a good time to standardize all the test scripts and reduce
the possibility of having to alter them all in the future if something
changes.
For example we could decide on an alternate way of choosing to run
network tests, or a new way of deciding to output debug information.
There are also some inconsistencies in the messages produced by tests
skipping all, and even an unfortunate mistake that has been copy/pasted
through a lot of test scripts.
My solution is t/lib/BioperlTest.pm (documented with perldoc)
We go from this:
----
use strict;
our $DEBUG;
BEGIN {
$DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
eval { require Test::More; };
if( $@ ) {
use lib 't/lib';
}
use Test::More; # the mistake!
use Module::Build;
my $build = Module::Build->current();
my $do_network_tests = $build->notes('network');
eval {
require IO::String;
require LWP;
require LWP::UserAgent;
};
if ($@) {
plan skip_all => 'IO::String or LWP or LWP::UserAgentnot installed.
This means Bio::Tools::Run::RemoteBlast is not usable. Skipping tests';
}
elsif (!$do_network_tests) {
plan skip_all => 'Network tests have not been requested, skipping
all';
}
else {
plan tests => 21;
}
#...
}
my $obj = Bio::Object->new(-verbose => $DEBUG);
#...
----
To this:
----
use strict;
BEGIN {
use lib 't/lib';
use BioperlTest;
test_begin(-requires_modules => [qw(IO::String LWP LWP::UserAgent)],
-requires_networking => 1,
-tests => 21);
#...
}
my $obj = Bio::Object->new(-verbose => test_debug());
#...
----
Can anyone identify problems with this approach? Is the interface
presented by BioperlTest flexible enough that any changes would only be
additions for new functionality (and therefore all test scripts wouldn't
need to be altered)? Is BioperlTest missing anything you'd like?
Are there any objections to me updating all tests in this manner? For an
example, see t/RemoteBlast.t
Cheers,
Sendu.
More information about the Bioperl-l
mailing list