Test::Auto::Subtests
Testing Automation
package main; use Test::Auto; use Test::Auto::Parser; use Test::Auto::Subtests; my $test = Test::Auto->new( 't/Test_Auto_Subtests.t' ); my $parser = Test::Auto::Parser->new( source => $test ); my $subtests = Test::Auto::Subtests->new( parser => $parser ); # execute dynamic subtests # $subtests->standard
This package use the Test::Auto::Parser object to execute a set of dynamic subtests.
This package uses type constraints from:
Data::Object::Library
This package has the following attributes:
parser(InstanceOf["Test::Auto::Parser"])
This attribute is read-only, accepts (InstanceOf["Test::Auto::Parser"]) values, and is required.
(InstanceOf["Test::Auto::Parser"])
This package implements the following methods:
attributes() : Any
This method registers and executes a subtest which tests the declared attributes.
# given: synopsis $subtests->attributes;
document() : Any
This method registers and executes a subtest which tests the test document structure.
# given: synopsis $subtests->document;
evaluator(Str $context) : Any
This method evaluates (using eval) the context given and returns the result or raises an exception.
eval
# given: synopsis my $context = '1 + 1'; $subtests->evaluator($context); # 2
example(Num $number, Str $name, Str $type, CodeRef $callback) : Any
This method finds and evaluates (using eval) the documented example and returns a Data::Object::Try object. The try object can be used to trap exceptions using the catch method, and/or execute the code and return the result using the result method.
try
catch
result
# given: synopsis $subtests->example(1, 'evaluator', 'method', sub { my ($tryable) = @_; ok my $result = $tryable->result, 'result ok'; is $result, 2, 'meta evaluator test ok'; $result; });
functions() : Any
This method registers and executes a subtest which tests the declared functions.
# given: synopsis $subtests->functions;
inherits() : Any
This method registers and executes a subtest which tests the declared inheritances.
# given: synopsis $subtests->inherits;
libraries() : Any
This method registers and executes a subtest which tests the declared type libraries.
# given: synopsis $subtests->libraries;
methods() : Any
This method registers and executes a subtest which tests the declared methods.
# given: synopsis $subtests->methods;
package() : Any
This method registers and executes a subtest which tests the declared package.
# given: synopsis $subtests->package;
registry() : InstanceOf["Type::Registry"]
This method returns a type registry object comprised of the types declare in the declared type libraries.
# given: synopsis my $registry = $subtests->registry;
routines() : Any
This method registers and executes a subtest which tests the declared routines.
# given: synopsis $subtests->routines;
standard() : InstanceOf["Test::Auto::Subtests"]
This method is shorthand which registers and executes a series of other standard subtests.
# given: synopsis # use: $subtests->standard; # instead of: # $self->package; # $self->document; # $self->libraries; # $self->inherits; # $self->attributes; # $self->methods; # $self->routines; # $self->functions;
synopsis(CodeRef $callback) : Any
This method evaluates (using eval) the documented synopsis and returns a Data::Object::Try object. The try object can be used to trap exceptions using the catch method, and/or execute the code and return the result using the result method.
# given: synopsis $subtests->synopsis(sub { my ($tryable) = @_; ok my $result = $tryable->result, 'result ok'; is ref($result), 'Test::Auto::Subtests', 'isa ok'; $result; });
tryable(Any @arguments) : InstanceOf["Data::Object::Try"]
This method returns a tryable object which can be used to defer code execution with a try/catch construct.
# given: synopsis my $tryable = $subtests->tryable; $tryable->call(sub { $_[0] + 1 }); # $tryable->result(1); #> 2
# given: synopsis my $tryable = $subtests->tryable(1); $tryable->call(sub { $_[0] + $_[1] }); # $tryable->result(1); #> 2
To install Test::Auto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Auto
CPAN shell
perl -MCPAN -e shell install Test::Auto
For more information on module installation, please visit the detailed CPAN module installation guide.