line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::BDD::Cucumber::Extension; |
2
|
|
|
|
|
|
|
$Test::BDD::Cucumber::Extension::VERSION = '0.84'; |
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::BDD::Cucumber::Extension - Abstract superclass for extensions |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
version 0.84 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Provides an abstract superclass for extensions. Loaded extensions will |
14
|
|
|
|
|
|
|
have their hook-implementations triggered at specific points during |
15
|
|
|
|
|
|
|
the BDD script execution. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
5353
|
use Moo; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
55
|
|
20
|
3
|
|
|
3
|
|
1028
|
use Types::Standard qw( HashRef ); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
38
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 PROPERTIES |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 config |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
A hash, the configuration read from the config file, verbatim. Extensions |
28
|
|
|
|
|
|
|
should look for their own configuration in |
29
|
|
|
|
|
|
|
$self->config->{extensions}->{} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has config => ( is => 'rw', isa => HashRef ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 steps_directories() |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
The returns an arrayref whose values enumerate directories (relative to |
40
|
|
|
|
|
|
|
the directory of the extension) which hold step files to be loaded when |
41
|
|
|
|
|
|
|
the extension is loaded. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
0
|
sub step_directories { return []; } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 pre_execute($app) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Invoked by C before executing any features. This callback |
50
|
|
|
|
|
|
|
allows generic extension setup. Reports errors by calling croak(). It is |
51
|
|
|
|
|
|
|
called once per C instance. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Note that the C plugin for C |
54
|
|
|
|
|
|
|
might instantiate multiple C objects, meaning it will create |
55
|
|
|
|
|
|
|
multiple instances of the extensions too. As such, this callback may be |
56
|
|
|
|
|
|
|
called once per instance, but multiple times in a Perl image. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The source handler Cs the running Perl instance in order to support |
59
|
|
|
|
|
|
|
the parallel testing C<-j> option. This callback will be called pre-fork. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 post_execute() |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Invoked by C after executing all features. This callback |
64
|
|
|
|
|
|
|
allows generic extension teardown and cleanup. Reports errors by calling |
65
|
|
|
|
|
|
|
croak(). |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Note: When the C plugin for C |
68
|
|
|
|
|
|
|
is used, there are no guarantees at this point that this hook is called |
69
|
|
|
|
|
|
|
only once. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
1
|
1
|
31
|
sub pre_execute { return; } |
74
|
1
|
|
|
1
|
1
|
31
|
sub post_execute { return; } |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 pre_feature($feature, $feature_stash) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Invoked by the Executor before executing the background and feature scenarios |
79
|
|
|
|
|
|
|
and their respective pre-hooks. Reports errors by calling croak(). |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 post_feature($feature, $feature_stash) |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Invoked by the Executor after executing the background and feature scenarios |
84
|
|
|
|
|
|
|
and their respective post-hooks. Reports errors by calling croak(). |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
1
|
1
|
3
|
sub pre_feature { return; } |
89
|
1
|
|
|
1
|
1
|
4
|
sub post_feature { return; } |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 pre_scenario($scenario, $feature_stash, $scenario_stash) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Invoked by the Executor before executing the steps in $scenario and |
94
|
|
|
|
|
|
|
their respective pre-hooks. Reports errors by calling croak(). |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 post_scenario($scenario, $feature_stash, $scenario_stash, $failed) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Invoked by the Executor after executing all the steps in $scenario |
99
|
|
|
|
|
|
|
and their respective post-hooks. Reports errors by calling croak(). |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$failure indicates whether any of the steps in the scenario has failed. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
1
|
1
|
2
|
sub pre_scenario { return; } |
106
|
1
|
|
|
1
|
1
|
4
|
sub post_scenario { return; } |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 pre_step($stepdef, $step_context) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Invoked by the Executor before executing each step in $scenario. |
111
|
|
|
|
|
|
|
Reports errors by calling croak(). |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
C<$stepdef> contains a reference to an array with step data: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
[ qr//, { meta => $data }, $code ] |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Feature and scenario stashes can be reached through |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$step_context->stash->{feature} |
120
|
|
|
|
|
|
|
# and |
121
|
|
|
|
|
|
|
$step_context->stash->{scenario} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Feature, scenario and step (from the feature file) are available as |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$step_context->feature |
126
|
|
|
|
|
|
|
$step_context->scenario |
127
|
|
|
|
|
|
|
$step_context->step |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Note: B steps, so not called for skipped steps. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 post_step($stepdef, $step_context, $failed, $result) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Invoked by the Executor after each executed step in $scenario. |
134
|
|
|
|
|
|
|
Reports errors by calling croak(). |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$failed indicates that the step has not been completed successfully; |
137
|
|
|
|
|
|
|
this means the step can have failed, be marked as TODO or pending |
138
|
|
|
|
|
|
|
(not implemented). |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
$result is a C instance which |
141
|
|
|
|
|
|
|
holds the completion status of the step. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Note: B steps, so not called for skipped steps. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
0
|
1
|
0
|
sub pre_step { return; } |
148
|
3
|
|
|
3
|
1
|
10
|
sub post_step { return; } |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Erik Huelsmann C |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright 2016-2023, Erik Huelsmann; Licensed under the same terms as Perl |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |