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