line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
11
|
|
|
11
|
|
108364
|
use v5.14; |
|
11
|
|
|
|
|
59
|
|
2
|
11
|
|
|
11
|
|
69
|
use warnings; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
505
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Test::BDD::Cucumber::Harness::Data 0.86; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Test::BDD::Cucumber::Harness::Data - Builds up an internal data representation of test passes / failures |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
version 0.86 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
A L subclass which collates test data |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
11
|
|
603
|
use Moo; |
|
11
|
|
|
|
|
11137
|
|
|
11
|
|
|
|
|
71
|
|
21
|
11
|
|
|
11
|
|
5911
|
use Types::Standard qw( HashRef ArrayRef ); |
|
11
|
|
|
|
|
75012
|
|
|
11
|
|
|
|
|
102
|
|
22
|
11
|
|
|
11
|
|
8313
|
use Test::More; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
130
|
|
23
|
11
|
|
|
11
|
|
4530
|
use Test::BDD::Cucumber::Model::Result; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
8062
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
extends 'Test::BDD::Cucumber::Harness'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 features |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
An array-ref in which we store all the features executed, and completed. Until |
32
|
|
|
|
|
|
|
C is called, it won't be in here. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'features' => ( is => 'rw', isa => ArrayRef, default => sub { [] } ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 current_feature |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 current_scenario |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 current_step |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The current feature/step/scenario for which we've had the starting method, but |
45
|
|
|
|
|
|
|
not the C<_done> method. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has 'current_feature' => |
50
|
|
|
|
|
|
|
( is => 'rw', isa => HashRef, default => sub { {} } ); |
51
|
|
|
|
|
|
|
has 'current_scenario' => |
52
|
|
|
|
|
|
|
( is => 'rw', isa => HashRef, default => sub { {} } ); |
53
|
|
|
|
|
|
|
has 'current_step' => ( is => 'rw', isa => HashRef, default => sub { {} } ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 feature |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 feature_done |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Feature hashref looks like: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
object => Test::BDD::Cucumber::Model::Feature object |
63
|
|
|
|
|
|
|
scenarios => [] |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# We will keep track of where we are each time... |
69
|
|
|
|
|
|
|
sub feature { |
70
|
13
|
|
|
13
|
1
|
45
|
my ( $self, $feature ) = @_; |
71
|
13
|
|
|
|
|
66
|
my $feature_ref = { |
72
|
|
|
|
|
|
|
object => $feature, |
73
|
|
|
|
|
|
|
scenarios => [] |
74
|
|
|
|
|
|
|
}; |
75
|
13
|
|
|
|
|
249
|
$self->current_feature($feature_ref); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub feature_done { |
79
|
21
|
|
|
21
|
1
|
45
|
my $self = shift; |
80
|
21
|
|
|
|
|
46
|
push( @{ $self->features }, $self->current_feature ); |
|
21
|
|
|
|
|
411
|
|
81
|
21
|
|
|
|
|
837
|
$self->current_feature( {} ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 scenario |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 scenario_done |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Scenario hashref looks like: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
object => Test::BDD::Cucumber::Model::Scenario object |
92
|
|
|
|
|
|
|
dataset => Data hash the scenario was invoked with |
93
|
|
|
|
|
|
|
steps => [], |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub scenario { |
99
|
26
|
|
|
26
|
1
|
117
|
my ( $self, $scenario, $dataset ) = @_; |
100
|
26
|
|
|
|
|
115
|
my $scenario_ref = { |
101
|
|
|
|
|
|
|
object => $scenario, |
102
|
|
|
|
|
|
|
dataset => $dataset, |
103
|
|
|
|
|
|
|
steps => [], |
104
|
|
|
|
|
|
|
}; |
105
|
26
|
|
|
|
|
544
|
$self->current_scenario($scenario_ref); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub scenario_done { |
109
|
26
|
|
|
26
|
1
|
56
|
my $self = shift; |
110
|
26
|
|
|
|
|
51
|
push( @{ $self->current_feature->{'scenarios'} }, $self->current_scenario ); |
|
26
|
|
|
|
|
560
|
|
111
|
26
|
|
|
|
|
1075
|
$self->current_scenario( {} ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 step |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 step_done |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Step hashref looks like: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
context => Test::BDD::Cucumber::StepContext object |
122
|
|
|
|
|
|
|
result => Test::BDD::Cucumber::Model::Result object (after step_done) |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub step { |
128
|
60
|
|
|
60
|
1
|
148
|
my ( $self, $step_context ) = @_; |
129
|
60
|
|
|
|
|
164
|
my $step_ref = { context => $step_context }; |
130
|
60
|
|
|
|
|
1228
|
$self->current_step($step_ref); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub step_done { |
134
|
60
|
|
|
60
|
1
|
156
|
my ( $self, $context, $result, $highlights ) = @_; |
135
|
|
|
|
|
|
|
|
136
|
60
|
|
|
|
|
1344
|
$self->current_step->{'result'} = $result; |
137
|
60
|
|
|
|
|
1300
|
$self->current_step->{'highlights'} = $highlights; |
138
|
60
|
|
|
|
|
377
|
push( @{ $self->current_scenario->{'steps'} }, $self->current_step ); |
|
60
|
|
|
|
|
960
|
|
139
|
60
|
|
|
|
|
2224
|
$self->current_step( {} ); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 feature_status |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 scenario_status |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 step_status |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Accepting one of the data-hashes above, returns a |
149
|
|
|
|
|
|
|
L object representing it. If it's a Feature |
150
|
|
|
|
|
|
|
or a Scenario, then it returns one representing all the child objects. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Status methods |
155
|
|
|
|
|
|
|
sub feature_status { |
156
|
2
|
|
|
2
|
1
|
88
|
my ( $self, $feature ) = @_; |
157
|
|
|
|
|
|
|
return Test::BDD::Cucumber::Model::Result->from_children( |
158
|
2
|
|
|
|
|
6
|
map { $self->scenario_status($_) } @{ $feature->{'scenarios'} } ); |
|
1
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
10
|
|
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub scenario_status { |
162
|
16
|
|
|
16
|
1
|
3176
|
my ( $self, $scenario ) = @_; |
163
|
|
|
|
|
|
|
return Test::BDD::Cucumber::Model::Result->from_children( |
164
|
16
|
|
|
|
|
34
|
map { $self->step_status($_) } @{ $scenario->{'steps'} } ); |
|
48
|
|
|
|
|
106
|
|
|
16
|
|
|
|
|
47
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub step_status { |
168
|
55
|
|
|
55
|
1
|
1547
|
my ( $self, $step ) = @_; |
169
|
55
|
|
|
|
|
187
|
return $step->{'result'}; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 find_scenario_step_by_name |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Given a Scenario and a string, searches through the steps for it and returns |
175
|
|
|
|
|
|
|
the data-hash where the Step Object's C<<->text>> matches the string. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Find a step |
180
|
|
|
|
|
|
|
sub find_scenario_step_by_name { |
181
|
3
|
|
|
3
|
1
|
25
|
my ( $self, $scenario, $name ) = @_; |
182
|
|
|
|
|
|
|
my ($step) = |
183
|
3
|
|
|
|
|
6
|
grep { $_->{'context'}->text eq $name } @{ $scenario->{'steps'} }; |
|
6
|
|
|
|
|
26
|
|
|
3
|
|
|
|
|
12
|
|
184
|
|
|
|
|
|
|
|
185
|
3
|
|
|
|
|
9
|
return $step; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 AUTHOR |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Peter Sergeant C |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 LICENSE |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Copyright 2019-2023, Erik Huelsmann |
195
|
|
|
|
|
|
|
Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; |