[Bioperl-l] test::more template

Nathan Haigh N.Haigh at sheffield.ac.uk
Thu Oct 19 13:38:25 EDT 2006

> Well, Analysis_soap.t ran immediately after, so Amap.t tests shouldn't be
> the problem.  The only issue I can think of is that Test::More TODO blocks
> require a newer version of Test::Harness (which most users have anyway).
> Are you using a TODO block?
> You can send me Amap.t and I'll give it a try, but I can't promise I'll get
> to it immediately (busy day).
> Chris
> Christopher Fields
> Postdoctoral Researcher - Switzer Lab
> Dept. of Biochemistry
> University of Illinois Urbana-Champaign 

No TODO blocks.

I must have done something wrong - it's the first time I've seen this - but then again, I don't look that closely at the output of "make test" unless
something shows as a fail. Anyway, below is the short bit of code.


use strict;
use Bio::Root::IO;  # cant test for this, might be needed to get Test::More

  # Things to do ASAP once the script is run
  # even before anything else in the file is parsed
  use vars qw($NUMTESTS $DEBUG $error);

  # Use installed Test module, otherwise fall back
  # to copy of Test.pm located in the t dir
  eval { require Test::More; };
  if ( $@ ) {
    use lib Bio::Root::IO->catfile('t','lib');

  # Currently no errors
  $error = 0;

  # Setup the number of tests to be run
  # what about using:
  # use Test::More 'no_plan';
  use Test::More;
  $NUMTESTS = 10;
  plan tests => $NUMTESTS;

  # Use modules that are needed in this test that are from
  # any of the Bioperl packages: Bioperl-core, Bioperl-run ... etc
  # use_ok('<module::to::use>');

# Multiple END blocks are run in reverse order of their definition
# Last In, First Out (LIFO)
  # Things to do right at the very end, just
  # when the  interpreter finishes/exits
  # E.g. deleting intermediate files produced during the test

  foreach my $file ( qw(cysprot.dnd cysprot1a.dnd) ) {
    unlink $file;
    # check it was deleted

  #unlink qw(cysprot.dnd cysprot1a.dnd)

  # Not sure what this is doing?
  #for ( $Test::ntest..$NUMTESTS ) {
  #  skip("Amap program not found. Skipping.\n",1);

# if we got to here, thats OK!
# is this really needed?
ok( 1, 'All the required modules are present');

# setup input files etc
my $inputfilename = Bio::Root::IO->catfile("t","data","cysprot.fa");

# setup output files etc
# none in this test

# setup global objects that are to be used in more than one test
# Also test they were initialised correctly
my @params = ();
my $aln;
my $factory = Bio::Tools::Run::Alignment::Amap->new(@params);
ok( defined $factory,                                  'new() returned something' );
ok( $factory->isa('Bio::Tools::Run::Alignment::Amap'), '  and its the right class' );

# Now onto the nitty gritty tests of the modules methods
my $executable_file = $factory->executable();
#is( $factory->executable(), 'filename',                'executable() got the correct filename' );

# block of tests to skip if you know the tests will fail
# under some condition. E.g.:
#   Need network access,
#   Wont work on particular OS,
#   Cant find the exectuable
# Do not just skip tests that seem to fail for an unknown reason
  # condition used to skip this block of tests
  #skip($why, $how_many_in_block);
  skip("Got incorrect filename for executable", 2)
    unless is($factory->executable(), 'filename',       'executable() got the correct filename');

  ok( -e $executable_file,                              'Found executable' );
  ok( $factory->version >= 2.0,                         'Code tested on Amap versions >= 2.0' );


More information about the Bioperl-l mailing list