Test::StubGenerator is a simple module that analyzes a given source file and automatically generates t/*.t style tests for subroutines/methods it encounters.
SYNOPSIS
use Test::StubGenerator;
my $stub = Test::StubGenerator->new(
{
file => '/path/to/MyModule.pm',
tidy => 1,
}
);
print $stub->gen_testfile;
Or, from the command line (split for easier reading):
$ perl -MTest::StubGenerator -e '
> my $stub = Test::StubGenerator->new({ file => "Module.pm" });
> print $stub->gen_testfile;' > Module.t
Test::StubGenerator is a module that attempts to analyze a given source file and automatically create testing stubs suitable for unit testing your code.
Test::StubGenerator make use of PPI in order to parse your code, looking for constructors and methods for modules (.pm), and subroutines for Perl script files (.pl).
Test::StubGenerator also runs the generated tests through Perl::Tidy before returning the text of the tests to you, though this can be disabled.
The idea for Test::StubGenerator grew out of a vim plugin I wrote that created test stub files in a very similar fashion. However, the line-based nature of vimscript quickly indicated that adding default parameters to the tests would prove to be an exercise in futility. As this was a feature I very much wanted to implement, I naturally turned to Perl, and PPI.
Product's homepage
Requirements:
· Perl