File Coverage

blib/lib/Test/BDD/Cucumber/Extension.pm
Criterion Covered Total %
statement 18 20 90.0
branch n/a
condition n/a
subroutine 11 13 84.6
pod 8 9 88.8
total 37 42 88.1


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