NAME
Test::Auto::Subtests
ABSTRACT
Testing Automation
SYNOPSIS
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
DESCRIPTION
This package use the Test::Auto::Parser object to execute a set of dynamic subtests.
LIBRARIES
This package uses type constraints from:
ATTRIBUTES
This package has the following attributes:
parser
parser(InstanceOf["Test::Auto::Parser"])
This attribute is read-only, accepts (InstanceOf["Test::Auto::Parser"])
values, and is required.
METHODS
This package implements the following methods:
attributes
attributes() : Any
This method registers and executes a subtest which tests the declared attributes.
document
document() : Any
This method registers and executes a subtest which tests the test document structure.
evaluator
evaluator(Str $context) : Any
This method evaluates (using eval
) the context given and returns the result or raises an exception.
example
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.
- example example #1
-
# 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
functions() : Any
This method registers and executes a subtest which tests the declared functions.
inherits
inherits() : Any
This method registers and executes a subtest which tests the declared inheritances.
libraries
libraries() : Any
This method registers and executes a subtest which tests the declared type libraries.
methods
methods() : Any
This method registers and executes a subtest which tests the declared methods.
package
package() : Any
This method registers and executes a subtest which tests the declared package.
registry
registry() : InstanceOf["Type::Registry"]
This method returns a type registry object comprised of the types declare in the declared type libraries.
routines
routines() : Any
This method registers and executes a subtest which tests the declared routines.
standard
standard() : InstanceOf["Test::Auto::Subtests"]
This method is shorthand which registers and executes a series of other standard subtests.
- standard example #1
-
# given: synopsis # use: $subtests->standard; # instead of: # $self->package; # $self->document; # $self->libraries; # $self->inherits; # $self->attributes; # $self->methods; # $self->routines; # $self->functions;
synopsis
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.
- synopsis example #1
-
# given: synopsis $subtests->synopsis(sub { my ($tryable) = @_; ok my $result = $tryable->result, 'result ok'; is ref($result), 'Test::Auto::Subtests', 'isa ok'; $result; });
tryable
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.