[Bioperl-l] Test Suite and Test::Exception

Nathan Haigh n.haigh at sheffield.ac.uk
Tue Mar 13 12:38:15 UTC 2007


I've really started looking into tests while writing some of my own
modules and I've found Test::Exception pretty good at testing things you
would expect to die and live. I know things like this can be done with
an eval block, but Test::Exception is nice and tidy and provides
throws_ok etc to test if a certain message was thrown (using a string or
regex). I think it could be pretty useful for use in BioPerl tests,
especially if tests are to be devised to cover some of the metrics
provided by Devel::Cover e.g. Branch coverage.

For a quick example: test that an error is thrown when providing an
inappropriate parameter to one of the bioperl-run modules (e.g.
Clustalw.pm).

-- start test code --
#  Build a clustalw alignment factory
my @params = ('unknown_param_name' => 2);
$factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
dies_ok{  Bio::Tools::Run::Alignment::Clustalw->new(@params);}
"Correctly died when using an unknown parameter";
-- end test code --

However, Test::Exception isn't installed by default. In addition, these
types of tests could inflate the test suit - is this, or could this be
an issue?

Anywho, any thoughts on this?
Nath



More information about the Bioperl-l mailing list