NAME
Test::NaiveStubs - Generate test stubs for methods and functions
VERSION
version 0.0400
SYNOPSIS
use Test::NaiveStubs;
my $tns = Test::NaiveStubs->new(
module => 'Foo::Bar',
name => 't/foo-bar.t',
);
$tns->create_test;
DESCRIPTION
Test::NaiveStubs
generates a test file of stubs exercising all the methods or functions of a given module (the module attribute).
Unfortunately Class::Sniff returns imported methods as well as the ones in the module you have given. So you will have to remove those lines from the generated test file by hand.
For a more powerful alternative, check out Test::StubGenerator.
ATTRIBUTES
module
$module = $tns->module;
The module name to use in the test generation.
name
$name = $tns->name;
The test output file name. If not given in the constructor, the filename is created from the module. So Foo::Bar
would be converted to foo-bar.t
.
METHODS
new()
$tns = Test::NaiveStubs->new(%arguments);
Create a new Test::NaiveStubs
object.
gather_methods()
$methods = $tns->gather_methods;
Return the methods of the given module, as well as imported methods, as a hash reference.
unit_test()
$test = $tns->unit_test($method);
Return the text of a method unit test.
create_test()
$tns->create_test;
Create a test file with unit tests for each method.
A new
method is extracted and processed first with use_ok
, object instantiation, followed by isa_ok
. Then each seen method is returned as an ok can("method") assertion.
SEE ALSO
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2019 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.