Gherkin/Node/Background.pm

filter: Statementstmt 100% 33 / 33 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 12.5% 1 / 8 totaltotal 84.7% 50 / 59 CC 5 SCAR 4.2
CC
5
Cov
95%
steps
2.1
nsteps
2.0
title
2.0
CRAP 1.5
« Gherkin/Lexer.pm ↑ Summary Gherkin/Node/Feature.pm »
1 package Test::Pcuke::Gherkin::Node::Background;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use base 'Test::Pcuke::Gherkin::Node';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Test::Cucumber::Background - background of the scenarios in a feature
11  
12 =head1 SYNOPSIS
13  
14 TODO synopsis
15  
16 use Test::Pcuke::Gherkin::Node::Background;
17  
18 my $background = Test::Pcuke::Gherkin::Node::Background->new();
19 # TODO code example
20  
21 =head1 METHODS
22  
23 =head2 new
24  
25 =cut
26  
27 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
28 4 my ($class, $args) = @_;
29
30 4 my $self = $class->SUPER::new(
31 immutables => ['title'],
32 properties => ['steps'],
33 args => $args,
34 );
35
36 4 $self->_clear_stats;
37
38 4 return $self;
39 }
40  
41 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
42 2 ▶sub set_title { $_[0]->_set_immutable('title', $_[1]) }
Subroutine set_title: called CC=1 SCAR=0.0
Pod undocumented
43  
44 2 ▶sub add_step {
Subroutine add_step: called CC=1 SCAR=0.0
Pod undocumented
45 2 my ($self, $step) = @_;
46 2 $self->_add_property('steps', $step);
47 }
48  
49 2 ▶sub steps { $_[0]->_get_property('steps') || []; }
Subroutine steps: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->_get_property("steps") or [] 2 0 2
50  
51 2 ▶sub execute {
Subroutine execute: called CC=2 SCAR=6.9
Pod undocumented
52 2 my ($self) = @_;
53
54 2 $self->_clear_stats;
55
56 2 my $steps = $self->_get_property('steps');
57
58 2 for ( @$steps ) {
59 4 $_->execute();
60 4 $self->collect_stats( $_ );
61 }
62 }
63  
64 4 ▶sub collect_stats {
Subroutine collect_stats: called CC=1 SCAR=0.0
Pod undocumented
65 4 my ($self, $step) = @_;
66
67 4 my $nsteps = $self->nsteps;
68 4 $nsteps->{ $step->status }++;
69 4 $self->_set_property('_nsteps', $nsteps);
70 }
71  
72 6 ▶sub _clear_stats { $_[0]->_set_property('_nsteps', {fail=>0, pass=>0, undef=>0}) }
Subroutine _clear_stats: called CC=1 SCAR=0.0
73  
74 6 ▶sub nsteps {
Subroutine nsteps: called CC=2 SCAR=7.1
Pod undocumented
75 6 my ($self, $status) = @_;
76 6 my $nsteps = $self->_get_property('_nsteps');
77
78 return $status ?
79 6 ▶ $nsteps->{$status}
Branch: 1 branch
BranchTrueFalseTotal
$status ? : 0 6 6
80 : $nsteps;
81 }
82  
83 3 1; # End of Test::Cucumber::Background
84 __END__
« Gherkin/Lexer.pm ↑ Summary Gherkin/Node/Feature.pm »