[Bioperl-l] test framework

Heikki Lehvaslaiho heikki@ebi.ac.uk
Thu, 04 Jan 2001 10:38:43 +0000


Since it is already in perl 5.004, there should be no reason not to
use it.
I tried it yesterday it really cleans up test code nicely. I am going
to use it in the future.

	-Heikki

Jason Stajich wrote:
> 
> while I'm messing with it, does anyone have objections to using the built
> in perl Test module available since perl 5.004 rather than our
> 
> I agree it is wasted time to constantly move things from one test suite to
> another ( I already tried to standardize our existing ones as best as
> possible).  But a nice standard makes it easier for new people to write
> tests and make them fit.  Any comments?
> 
> sub test ($$;$) {
>     my($num, $true,$msg) = @_;
>     print($true ? "ok $num\n" : "not ok $num $msg\n");
> }
> 
> [ from perldoc Test ]
> 
>       use strict;
>        use Test;
> 
>        # use a BEGIN block so we print our plan before MyModule is loaded
>        BEGIN { plan tests => 14, todo => [3,4] }
> 
>        # load your module...
>        use MyModule;
> 
>        ok(0); # failure
>        ok(1); # success
> 
>        ok(0); # ok, expected failure (see todo list, above)
>        ok(1); # surprise success!
> 
>        ok(0,1);             # failure: '0' ne '1'
>        ok('broke','fixed'); # failure: 'broke' ne 'fixed'
>        ok('fixed','fixed'); # success: 'fixed' eq 'fixed'
>        ok('fixed',qr/x/);   # success: 'fixed' =~ qr/x/
> 
>      ok(sub { 1+1 }, 2);  # success: '2' eq '2'
>        ok(sub { 1+1 }, 3);  # failure: '2' ne '3'
>        ok(0, int(rand(2));  # (just kidding :-)
> 
>        my @list = (0,0);
>        ok @list, 3, "\@list=".join(',',@list);      #extra diagnostics
>        ok 'segmentation fault', '/(?i)success/';    #regex match
> 
>        skip($feature_is_missing, ...);    #do platform specific test
> 
> Jason Stajich
> jason@chg.mc.duke.edu
> Center for Human Genetics
> Duke University Medical Center
> http://www.chg.duke.edu/
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l

-- 
______ _/      _/_____________________________________________________
      _/      _/                      http://www.ebi.ac.uk/mutations/
     _/  _/  _/  Heikki Lehvaslaiho          heikki@ebi.ac.uk
    _/_/_/_/_/  EMBL Outstation, European Bioinformatics Institute
   _/  _/  _/  Wellcome Trust Genome Campus, Hinxton
  _/  _/  _/  Cambs. CB10 1SD, United Kingdom
     _/      Phone: +44 (0)1223 494 644   FAX: +44 (0)1223 494 468
___ _/_/_/_/_/________________________________________________________