NAME
Test::NaiveStubs - Generate test stubs for methods
VERSION
version 0.0300
SYNOPSIS
use Test::NaiveStubs;
my $tns = Test::NaiveStubs->new(
class => 'Foo::Bar',
name => 't/foo-bar.t',
);
$tns->create_test;
DESCRIPTION
Test::NaiveStubs
generates a test file of stubs for exercising all the methods (not functions) of a given class.
Unfortunately Class::Sniff returns imported methods as well as the ones in the class 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
class
$class = $tns->class;
The class 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 class. 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 class, 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.