Gherkin/Node/Scenario.pm

filter: Statementstmt 94.2% 49 / 52 Branchbran 62.5% 10 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 11.1% 1 / 9 totaltotal 77.6% 73 / 94 CC 12 SCAR 11.3
CC
12
Cov
85%
execute
5.3
nscenarios
5.3
collect_stats
3.0
CRAP 3.1
« Gherkin/Parser.pm ↑ Summary Gherkin/Node/Step.pm »
1 package Test::Pcuke::Gherkin::Node::Scenario;
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use base 'Test::Pcuke::Gherkin::Node';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Test::Cucumber::Scenario - Represents a scenario
10  
11 =head1 SYNOPSIS
12  
13 Perhaps a little code snippet.
14  
15 use Test::Pcuke::Gherkin::Node::Scenario;
16 # TODO
17 ...
18  
19 =head1 METHODS
20  
21 =head2 new
22  
23 =cut
24  
25 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
26 6 my($class, $args) = @_;
27
28 6 my $properties = [ qw{steps _nsteps} ];
29 6 my $immutables = [ qw{title executor} ];
30
31 $args->{_nsteps} = {
32 6 pass=>0,
33 fail=>0,
34 undef=>0
35 };
36
37 6 my $self = $class->SUPER::new(
38 properties => $properties,
39 immutables => $immutables,
40 args => $args
41 );
42
43 6 return $self;
44 }
45  
46 5 ▶sub set_title {
Subroutine set_title: called CC=1 SCAR=0.0
Pod undocumented
47 5 my ($self, $title) = @_;
48 5 $self->_set_immutable('title', $title);
49 }
50  
51 3 ▶sub title { $_[0]->_get_immutable('title') || q{}; }
Subroutine title: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->_get_immutable("title") or "" 2 1 3
52  
53  
54 6 ▶sub add_step {
Subroutine add_step: called CC=1 SCAR=0.0
Pod undocumented
55 6 my ($self, $step) = @_;
56 6 $self->_add_property('steps', $step);
57 }
58  
59 1 ▶sub steps {
Subroutine steps: called CC=1 SCAR=0.0
Pod undocumented
60 1 my ($self) = @_;
61 1 return $self->_get_property('steps');
62 }
63  
64  
65 14 ▶sub nsteps {
Subroutine nsteps: called CC=2 SCAR=7.1
Pod undocumented
66 14 my ($self, $status) = @_;
67 14 my $nsteps = $self->_get_property('_nsteps');
68
69 return $status ?
70 14 ▶ $nsteps->{$status}
Branch: 1 branch
BranchTrueFalseTotal
$status ? : 0 14 14
71 : $nsteps;
72 }
73  
74 1 ▶sub nscenarios {
Subroutine nscenarios: called CC=4 SCAR=16.6
Pod undocumented
75 1 my ($self, $status) = @_;
76
77 1 my $nsteps = $self->nsteps;
78 1 my $nscenarios;
79
80 1 ▶ if ( $nsteps->{fail} > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nsteps->{'fail'} > 0) { } 1 0 1
elsif ($nsteps->{'undef'} > 0) { } 0 0 0
81 1 $nscenarios = { pass=>0, fail=>1, undef=>0 };
82 }
83 elsif ( $nsteps->{undef} > 0 ) {
84 0 $nscenarios = { pass=>0, fail=>0, undef=>1 };
85 }
86 else {
87 0 $nscenarios = { pass=>1, fail=>0, undef=>0 };
88 }
89
90 return $status ?
91 1 ▶ $nscenarios->{$status}
Branch: 1 branch
BranchTrueFalseTotal
$status ? : 0 1 1
92 : $nscenarios;
93 }
94  
95  
96 3 ▶sub execute {
Subroutine execute: called CC=5 SCAR=16.6
Pod undocumented
97 3 my ($self, $background) = @_;
98
99 3 my $executor = $self->_get_immutable('executor');
100 3 ▶ if ( $executor && $executor->can('reset_world') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($executor and $executor->can("reset_world")) 0 3 3
Condition33%1/3
$executor and $executor->can("reset_world")
!ll&&!rl&&r
300
MC/DC0%0/2
$executor and $executor->can("reset_world")
$executor $executor->can("reset_world")
Truth table33%1/3
A and B
A= $executorB= $executor->can("reset_world")
ABresult
0X0
100
111
101 0 $executor->reset_world;
102 }
103
104 3 my $steps = $self->_get_property('steps');
105
106 3 ▶ if ( $background ){
Branch: 1 branch
BranchTrueFalseTotal
if ($background) 1 2 3
107 1 $background->execute;
108 1 $self->collect_stats($background);
109 }
110
111 3 foreach my $step (@$steps) {
112 10 $step->execute();
113 10 $self->collect_stats($step);
114 }
115 }
116  
117 11 ▶sub collect_stats {
Subroutine collect_stats: called CC=3 SCAR=11.0
Pod undocumented
118 11 my ($self, $step) = @_;
119
120 11 my $nsteps = $self->nsteps;
121
122 11 ▶ if ( $step->can('nsteps') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($step->can('nsteps')) { } 1 10 11
123 1 my $bg_nsteps = $step->nsteps;
124 1 for (qw{pass fail undef}) {
125 3 $nsteps->{$_} += $bg_nsteps->{$_};
126 }
127 }
128 else {
129 # a step
130 10 $nsteps->{ $step->status }++;
131 }
132 }
133  
134  
135 3 1; # End of Test::Pcuke::Gherkin::Node::Scenario
136  
137 =head1 AUTHOR
138  
139 Andrei V. Toutoukine, C<< <tut at isuct.ru> >>
140  
141 =head1 BUGS
142  
143 Please report any bugs or feature requests to C<bug-/home/tut/bin/src/test-pcuke-gherkin at rt.cpan.org>, or through
144 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=/home/tut/bin/src/Test-Pcuke-Gherkin>. I will be notified, and then you'll
145 automatically be notified of progress on your bug as I make changes.
146  
147  
148  
149  
150 =head1 SUPPORT
151  
152 You can find documentation for this module with the perldoc command.
153  
154 perldoc Test::Pcuke::Gherkin::Node::Scenario
155  
156  
157 You can also look for information at:
158  
159 =over 4
160  
161 =item * RT: CPAN's request tracker
162  
163 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=/home/tut/bin/src/Test-Pcuke-Gherkin>
164  
165 =item * AnnoCPAN: Annotated CPAN documentation
166  
167 L<http://annocpan.org/dist//home/tut/bin/src/Test-Pcuke-Gherkin>
168  
169 =item * CPAN Ratings
170  
171 L<http://cpanratings.perl.org/d//home/tut/bin/src/Test-Pcuke-Gherkin>
172  
173 =item * Search CPAN
174  
175 L<http://search.cpan.org/dist//home/tut/bin/src/Test-Pcuke-Gherkin/>
176  
177 =back
178  
179  
180 =head1 ACKNOWLEDGEMENTS
181  
182  
183 =head1 LICENSE AND COPYRIGHT
184  
185 Copyright 2011 Andrei V. Toutoukine.
186  
187 This program is released under the following license: artistic
188  
189  
190 =cut
191  
« Gherkin/Parser.pm ↑ Summary Gherkin/Node/Step.pm »