1Test2::Workflow(3) User Contributed Perl Documentation Test2::Workflow(3)
2
3
4
6 Test2::Workflow - A test workflow is a way of structuring tests using
7 composable units.
8
10 A test workflow is a way of structuring tests using composable units. A
11 well known example of a test workflow is RSPEC <http://rspec.info/>.
12 RSPEC is implemented using Test2::Workflow in Test2::Tools::Spec along
13 with several extensions.
14
16 BUILD
17 Test2::Workflow::Build
18
19 A Build is used to compose tasks. Usually a build object is pushed to
20 the stack before running code that adds tasks to the build. Once the
21 build sub is complete the build is popped and returned. Usually a build
22 is converted into a root task or task group.
23
24 RUNNER
25 Test2::Workflow::Runner
26
27 A runner takes the composed tasks and executes them in the proper
28 order.
29
30 TASK
31 Test2::Workflow::Task
32
33 A task is a unit of work to accomplish. There are 2 main types of task.
34
35 ACTION
36
37 An action is the most simple unit used in composition. An action is
38 essentially a name and a codeblock to run.
39
40 GROUP
41
42 A group is a task that is composed of other tasks.
43
45 All exports are optional, you must request the ones you want.
46
47 $parsed = parse_args(args => \@args)
48 $parsed = parse_args(args => \@args, level => $L)
49 $parsed = parse_args(args => \@args, caller => [caller($L)])
50 This will parse a "typical" task builders arguments. The @args
51 array MUST contain a name (plain scalar containing text) and also a
52 single CODE reference. The @args array MAY also contain any
53 quantity of line numbers or hashrefs. The resulting data structure
54 will be a single hashref with all the provided hashrefs squashed
55 together, and the 'name', 'code', 'lines' and 'frame' keys set from
56 other arguments.
57
58 {
59 # All hashrefs from @args get squashed together:
60 %squashed_input_hashref_data,
61
62 # @args must have exactly 1 plaintext scalar that is not a number, it
63 # is considered the name:
64 name => 'name from input args'
65
66 # Integer values are treated as line numbers
67 lines => [ 35, 44 ],
68
69 # Exactly 1 coderef must be provided in @args:
70 code => \&some_code,
71
72 # 'frame' contains the 'caller' data. This may be passed in directly,
73 # obtained from the 'level' parameter, or automatically deduced.
74 frame => ['A::Package', 'a_file.pm', 42, ...],
75 }
76
77 $build = init_root($pkg, %args)
78 This will initialize (or return the existing) a build for the
79 specified package. %args get passed into the Test2::Workflow::Build
80 constructor. This uses the following defaults (which can be
81 overridden using %args):
82
83 name => $pkg,
84 flat => 1,
85 iso => 0,
86 async => 0,
87 is_root => 1,
88
89 Note that %args is completely ignored if the package build has
90 already been initialized.
91
92 $build = root_build($pkg)
93 This will return the root build for the specified package.
94
95 $build = current_build()
96 This will return the build currently at the top of the build stack
97 (or undef).
98
99 $build = build($name, \%params, sub { ... })
100 This will push a new build object onto the build stash then run the
101 provided codeblock. Once the codeblock has finished running the
102 build will be popped off the stack and returned.
103
104 See parse_args() for details about argument processing.
105
107 Test2::Tools::Spec
108 Test2::Tools::Spec is an implementation of RSPEC using this
109 library.
110
112 The source code repository for Test2-Workflow can be found at
113 https://github.com/Test-More/Test2-Suite/.
114
116 Chad Granum <exodist@cpan.org>
117
119 Chad Granum <exodist@cpan.org>
120
122 Copyright 2018 Chad Granum <exodist7@gmail.com>.
123
124 This program is free software; you can redistribute it and/or modify it
125 under the same terms as Perl itself.
126
127 See http://dev.perl.org/licenses/
128
129
130
131perl v5.36.0 2023-03-23 Test2::Workflow(3)