NAME

Test2::Workflow - Interface for writing 'workflow' tools such as RSPEC implementations that all play nicely together.

*** EXPERIMENTAL ***

This distribution is experimental, anything can change at any time!

DESCRIPTION

This module intends to do for 'workflow' test tools what Test::Builder and Test2 do for general test tools. The problem with workflow tools is that most do not play well together. This module is a very generic/abstract look at workflows that allows tools to be built that accomplish their workflows, but in a way that plays well with others.

SYNOPSIS

package My::Workflow::Tool;
use Test2::Workflow qw/gen_unit_builder/;

our @EXPORT = qw/my_wrapper/;
use base 'Exporter';

# Create a wrapping tool
*my_wrapper = gen_unit_builder('simple' => qw/buildup teardown/);

To use it:

use My::Workflow::Tool qw/my_wrapper/;

my_wrapper foo => sub {
    my $inner = shift;
    ...
    $inner->();
    ...
};

IMPORTANT CONCEPTS

A workflow is a way of defining tests with scaffolding. Essentially you are seperating your assertions and your setup/teardown/management code. This results in a separation of concerns that can produce more maintainable tests. In addition each component of a workflow can be re-usable and/or inheritable.

UNITS

Units are the small composable parts of a workflow. You can think of a unit as a named function that does some work. What separates a unit from a regular function is that it can have other units attashed to it in various ways. A unit can also be a 'group' unit, which means it contains other units as its primary work.

See Test2::Workflow::Unit.

PACKAGE UNIT

The package unit is the root 'group' unit for your test package. All other test units get put into the main package unit.

See Test2::Workflow::Meta where the primary unit is stored.

BUILDS

Units are generally defined using a DSL (Domain Specific Language). In this DSL you declare a unit, which gets added as the current build, then run code which modifies that build to turn it into the unit you need.

BUILD STACK

Builds can be defined within one another, as such the 'current' build is whatever build is on top of the build stack, which is a private array. There are low level functions exposed to give you control over the stack if you need it, but in general you should use a higher level tool.

TASK

A task is a composition of units to be run. The runner will compile you units into task form, then run the compiled tasks.

VAR STASH

There is a var stash. The var stash is a stack of hashes. Every time a task is run a new hash is pushed onto the stack. When a task is complete the hash is popped and cleared. Workflow tools may use this hash to store/define variables that will go away when the current task is complete.

EXPORTS

All exports are optional, you must request the ones you want.

BUILD STACK

VAR STASH

META DATA

CREATING UNITS

SEE ALSO

SOURCE

The source code repository for Test2-Workflow can be found at http://github.com/Test-More/Test2-Workflow/.

MAINTAINERS

AUTHORS

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/