On Saturday, March 29, 2003, at 07:22 AM, James E Keenan wrote:
I am preparing a module for distribution, including distribution on CPAN.
Having done this once before, I know _how_ to write a test suite using
standard Perl test modules. However, I'm still unclear as to what
constitutes a _good_ test. Suppose that I have a package that looks like
this:
my $enm = Exciting::New::Module->new('sourcefile', 'configfile'); my @outputfiles = qw(this_file that_file yet_another_file); $enm->print_this_way($outputfiles[0]); $enm->print_that_way($outputfiles[1]); $enm->print_third_way($outputfiles[2]); $enm->print_to_screen;
...where the constructor parses data from 'sourcefile' according to rules
established in 'configfile' and stores that data in a hash (or any other
appropriate structure) which is then blessed into the Exciting::New::Module
class. The various methods are merely different ways of extracting and
displaying data. Other than returning '1' to indicate that a file was
successfully printed, these methods are not expected to have a return value.
Is there any meaningful test to apply to these methods other than seeing if
'1' was returned?
Perhaps you need to create a method that returns the data rather than prints it. This could be used internally by the print_*_way() methods, and it would allow more thorough testing.
-Ken
