[Bioperl-l] New testing base: BioperlTest.pm
Chris Fields
cjfields at uiuc.edu
Mon Jun 25 13:39:21 UTC 2007
On Jun 25, 2007, at 8:06 AM, Sendu Bala wrote:
> Sendu Bala wrote:
>> In considering updating all the test scripts to [... use] t/lib/
>> BioperlTest.pm
>
> I'm now in the process of converting all test scripts. In addition to
> those things mentioned previously, BioperlTest now also provides the
> methods test_input_file() and test_output_file().
>
>
> This:
> ----
> use Bio::Root::IO;
> my $output_file = Bio::Root::IO->catfile(qw(t data temp.file));
> $obj->new(-file => ">$output_file");
>
> END {
> unlink($output_file);
> }
>
> ...
>
> $obj->new(-file => Bio::Root::IO->catfile(qw(t data input.file)));
> ----
>
>
> Becomes this:
> ----
> my $output_file = test_output_file();
> $obj->new(-file => ">$output_file");
>
> ...
>
> $obj->new(-file => test_input_file('input.file'));
> ----
>
>
> I should think the benefits are obvious, especially for the output
> files, which thanks to inconsistency of using END blocks correctly
> or at
> all, leaves some output data behind on occasion.
Sounds fine by me, though it's a lot of work. BTW, did we ever
decide whether to finish up with Test::More conversion? I haven't
heard back yet; let me know what you want to do.
> test_input_file() is helpful for the shorthand, but also gets rid of
> many tests' usage of Bio::Root::IO (relying on something you're
> installing and testing in another test script to work in the current
> test script, without testing it in your own test script seems like a
> no-no to me).
Well, in a way isn't that itself a test of the class (whether it
breaks or not)? ; >
Do test_input_file() and test_input_file() handle directory
structures in an OS-safe way like catfile()? For instance, I plan on
adding test data to a new directory similar to Bio::Graphics (t/data/
eutil) to prevent cluttering of the t/data directory. I could use
'$obj->new(-file => test_input_file('/eutil/input.xml'))' if the base
directory is 't/data' but that may not be cross-platform compatible
with win32 file systems, which may still expect something like 't\data
\eutil\input.xml'.
chris
More information about the Bioperl-l
mailing list