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

Chris Fields cjfields at uiuc.edu
Tue Mar 13 13:04:50 UTC 2007


You could add it to t/lib, which is what we do with Test::Simple/ 
More.  It seems like a worthwhile addition.  I have to agree with one  
of the CPAN reviewers, though, when using it in cases like your  
example; I would use throws_ok{}, which makes sure an exception was  
thrown and checks $@ using a qr{} (just to make sure the exception  
was the expected one and not something else like a nonexistent file,  
etc.).

chris

On Mar 13, 2007, at 7:38 AM, Nathan Haigh wrote:

> 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
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

Christopher Fields
Postdoctoral Researcher
Lab of Dr. Robert Switzer
Dept of Biochemistry
University of Illinois Urbana-Champaign






More information about the Bioperl-l mailing list