| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::BDD::Cucumber::Harness; |
|
2
|
|
|
|
|
|
|
$Test::BDD::Cucumber::Harness::VERSION = '0.84'; |
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::BDD::Cucumber::Harness - Base class for creating harnesses |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
version 0.84 |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Harnesses allow your feature files to be executed while telling the outside |
|
14
|
|
|
|
|
|
|
world about how the testing is going, and what's being tested. This is a base |
|
15
|
|
|
|
|
|
|
class for creating new harnesses. You can see |
|
16
|
|
|
|
|
|
|
L and |
|
17
|
|
|
|
|
|
|
L for examples, although if you need |
|
18
|
|
|
|
|
|
|
to interact with the results in a more exciting way, you'd be best off |
|
19
|
|
|
|
|
|
|
interacting with L. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS / EVENTS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
12
|
|
|
12
|
|
7130
|
use strict; |
|
|
12
|
|
|
|
|
39
|
|
|
|
12
|
|
|
|
|
386
|
|
|
26
|
12
|
|
|
12
|
|
98
|
use warnings; |
|
|
12
|
|
|
|
|
34
|
|
|
|
12
|
|
|
|
|
310
|
|
|
27
|
12
|
|
|
12
|
|
82
|
use Moo; |
|
|
12
|
|
|
|
|
36
|
|
|
|
12
|
|
|
|
|
72
|
|
|
28
|
12
|
|
|
12
|
|
4173
|
use Types::Standard qw( ArrayRef ); |
|
|
12
|
|
|
|
|
34
|
|
|
|
12
|
|
|
|
|
96
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'results' => ( is => 'ro', default => sub { [] }, isa => ArrayRef ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 feature |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 feature_done |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Called at the start and end of feature execution respectively. Both methods |
|
37
|
|
|
|
|
|
|
accept a single argument of a L. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
0
|
sub feature { my ( $self, $feature ) = @_; } |
|
42
|
9
|
|
|
9
|
1
|
77
|
sub feature_done { my ( $self, $feature ) = @_; } |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 background |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 background_done |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
If you have a background section, then we execute it as a quasi-scenario step |
|
49
|
|
|
|
|
|
|
before each scenario. These hooks are fired before and after that, and passed |
|
50
|
|
|
|
|
|
|
in the L that represents the Background |
|
51
|
|
|
|
|
|
|
section, and a a dataset hash (although why would you use that?) |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
31
|
|
|
31
|
1
|
151
|
sub background { my ( $self, $scenario, $dataset ) = @_; } |
|
56
|
31
|
|
|
31
|
1
|
121
|
sub background_done { my ( $self, $scenario, $dataset ) = @_; } |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 scenario |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 scenario_done |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Called at the start and end of scenario execution respectively. Both methods |
|
63
|
|
|
|
|
|
|
accept a L module and a dataset hash. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
0
|
sub scenario { my ( $self, $scenario, $dataset ) = @_; } |
|
68
|
0
|
|
|
0
|
1
|
0
|
sub scenario_done { my ( $self, $scenario, $dataset ) = @_; } |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 step |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 step_done |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Called at the start and end of step execution respectively. Both methods |
|
75
|
|
|
|
|
|
|
accept a L object. C also accepts |
|
76
|
|
|
|
|
|
|
a L object and an arrayref of arrayrefs with |
|
77
|
|
|
|
|
|
|
locations of consolidated matches, for highlighting. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
[ [2,5], [7,9] ] |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
1
|
0
|
sub step { my ( $self, $context ) = @_; } |
|
84
|
0
|
|
|
0
|
1
|
0
|
sub step_done { my ( $self, $context, $result ) = @_; } |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 sub_step |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 sub_step_done |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
As per C and C, but for steps that have been called from other |
|
91
|
|
|
|
|
|
|
steps. None of the included harnesses respond to these methods, because |
|
92
|
|
|
|
|
|
|
generally the whole thing should be transparent, and the parent step handles |
|
93
|
|
|
|
|
|
|
passes, failures, etc. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
12
|
|
|
12
|
1
|
41
|
sub sub_step { my ( $self, $context ) = @_; } |
|
98
|
12
|
|
|
12
|
1
|
34
|
sub sub_step_done { my ( $self, $context, $result ) = @_; } |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 startup |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 shutdown |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Some tests will run one feature, some will run many. For this reason, you may |
|
105
|
|
|
|
|
|
|
have harnesses that have something they need to do on start (print an HTML |
|
106
|
|
|
|
|
|
|
header), that they shouldn't do at the start of every feature, or a close-down |
|
107
|
|
|
|
|
|
|
task (like running C), that again shouldn't happen on I |
|
108
|
|
|
|
|
|
|
feature close-out, just the last. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Just C<$self> as the single argument for both. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
|
|
1
|
1
|
3
|
sub startup { my $self = shift; } |
|
115
|
0
|
|
|
0
|
1
|
0
|
sub shutdown { my $self = shift; } |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 add_result |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Called before C with the step's result. Expected to silently add the |
|
120
|
|
|
|
|
|
|
result in to a pool that facilitate the C method. No need to override |
|
121
|
|
|
|
|
|
|
this behaviour. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 result |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns a collective view on the passing status of all steps run so far, |
|
126
|
|
|
|
|
|
|
as a L object. Default implementation should |
|
127
|
|
|
|
|
|
|
be fine for all your needs. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub add_result { |
|
132
|
627
|
|
|
627
|
1
|
1112
|
my $self = shift; |
|
133
|
627
|
|
|
|
|
943
|
push( @{ $self->results }, shift() ); |
|
|
627
|
|
|
|
|
2052
|
|
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub result { |
|
137
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
138
|
|
|
|
|
|
|
return Test::BDD::Cucumber::Model::Result->from_children( |
|
139
|
1
|
|
|
|
|
3
|
@{ $self->results } ); |
|
|
1
|
|
|
|
|
10
|
|
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Peter Sergeant C |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 LICENSE |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Copyright 2019-2023, Erik Huelsmann |
|
149
|
|
|
|
|
|
|
Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; |