| 1 | package Test::Pcuke::Report; | ||||||||||||||||||||||||||||
| 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 Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | our $template; | |||||||||||||||||||||||||||
| 10 | 3 | our $blocks; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Test::Pcuke::Report - report builder | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | use Test::Pcuke::Report; | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | my $report = Test::Pcuke::Report->new( | ||||||||||||||||||||||||||||
| 21 | features_iterator => Test::Pcuke::Iterator->new( $self->{_executed_features} ), | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | $report->build(); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 METHODS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head2 new | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | my $self = {}; | |||||||||||||||||||||||||||
| 36 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | $self->set_features( $args{features} ) | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if $args{features}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $self->set_debug_template( $args{debug} || q{} ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'debug'} || ''
MC/DC0%0/1
$args{'debug'} || ''
$args{'debug'}
Truth table0%0/2
A
A= $args{'debug'}
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | return $self; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub set_debug_template { $_[0]->{debug_template} = $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
set_debug_template: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub debug_template { $_[0]->{debug_template} || undef } | ||||||||||||||||||||||||||
|
Subroutine
debug_template: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub set_features { | ||||||||||||||||||||||||||
|
Subroutine
set_features: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | my ($self, $features) = @_; | |||||||||||||||||||||||||||
| 50 | 0 | $self->{features} = $features; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub features { | ||||||||||||||||||||||||||
|
Subroutine
features: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 0 | return $_[0]->{features}; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub set_printer { | ||||||||||||||||||||||||||
|
Subroutine
set_printer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 0 | my ($self, $printer) = @_; | |||||||||||||||||||||||||||
| 59 | 0 | $self->{printer} = $printer; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub printer { $_[0]->{printer}; } | ||||||||||||||||||||||||||
|
Subroutine
printer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub build { | ||||||||||||||||||||||||||
|
Subroutine
build: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 66 | 0 | my $output; | |||||||||||||||||||||||||||
| 67 | 0 | my ($template, $blocks) = $self->_get_template; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | my $engine = Template->new( | ||||||||||||||||||||||||||
|
Condition0%0/2
'Template'->new('PRE_CHOMP', 1, 'POST_CHOMP', 1, 'PLUGIN_BASE', 'Template::Plugin::Filter', 'BLOCKS', $blocks, 'VARIABLES', {'stats', {'scenarios_failed', 0, 'scenarios_undefined', 0, 'scenarios_total', 0, 'steps_failed', 0, 'steps_undefined', 0, 'steps_total', 0}, 'colors', {'head', 'bold cyan', 'pass', 'green', 'fail', 'red', 'undef', 'yellow'}}, 'DEBUG', $self->debug_template) || confess('Template'->error, "\n")
MC/DC0%0/1
'Template'->new('PRE_CHOMP', 1, 'POST_CHOMP', 1, 'PLUGIN_BASE', 'Template::Plugin::Filter', 'BLOCKS', $blocks, 'VARIABLES', {'stats', {'scenarios_failed', 0, 'scenarios_undefined', 0, 'scenarios_total', 0, 'steps_failed', 0, 'steps_undefined', 0, 'steps_total', 0}, 'colors', {'head', 'bold cyan', 'pass', 'green', 'fail', 'red', 'undef', 'yellow'}}, 'DEBUG', $self->debug_template) || confess('Template'->error, "\n")
'Template'->new('PRE_CHOMP', 1, 'POST_CHOMP', 1, 'PLUGIN_BASE', 'Template::Plugin::Filter', 'BLOCKS', $blocks, 'VARIABLES', {'stats', {'scenarios_failed', 0, 'scenarios_undefined', 0, 'scenarios_total', 0, 'steps_failed', 0, 'steps_undefined', 0, 'steps_total', 0}, 'colors', {'head', 'bold cyan', 'pass', 'green', 'fail', 'red', 'undef', 'yellow'}}, 'DEBUG', $self->debug_template)
Truth table0%0/2
A
A= 'Template'->new('PRE_CHOMP', 1, 'POST_CHOMP', 1, 'PLUGIN_BASE', 'Template::Plugin::Filter', 'BLOCKS', $blocks, 'VARIABLES', {'stats', {'scenarios_failed', 0, 'scenarios_undefined', 0, 'scenarios_total', 0, 'steps_failed', 0, 'steps_undefined', 0, 'steps_total', 0}, 'colors', {'head', 'bold cyan', 'pass', 'green', 'fail', 'red', 'undef', 'yellow'}}, 'DEBUG', $self->debug_template)
| |||||||||||||||||||||||||||||
| 70 | PRE_CHOMP => 1, | ||||||||||||||||||||||||||||
| 71 | POST_CHOMP => 1, | ||||||||||||||||||||||||||||
| 72 | PLUGIN_BASE => 'Template::Plugin::Filter', | ||||||||||||||||||||||||||||
| 73 | BLOCKS => $blocks, | ||||||||||||||||||||||||||||
| 74 | VARIABLES => { | ||||||||||||||||||||||||||||
| 75 | stats => { | ||||||||||||||||||||||||||||
| 76 | scenarios_failed => 0, | ||||||||||||||||||||||||||||
| 77 | scenarios_undefined => 0, | ||||||||||||||||||||||||||||
| 78 | scenarios_total => 0, | ||||||||||||||||||||||||||||
| 79 | steps_failed => 0, | ||||||||||||||||||||||||||||
| 80 | steps_undefined => 0, | ||||||||||||||||||||||||||||
| 81 | steps_total => 0, | ||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||
| 83 | colors => { | ||||||||||||||||||||||||||||
| 84 | head => 'bold cyan', | ||||||||||||||||||||||||||||
| 85 | pass => 'green', | ||||||||||||||||||||||||||||
| 86 | fail => 'red', | ||||||||||||||||||||||||||||
| 87 | undef => 'yellow', | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | }, | ||||||||||||||||||||||||||||
| 91 | DEBUG => $self->debug_template, | ||||||||||||||||||||||||||||
| 92 | ) | ||||||||||||||||||||||||||||
| 93 | || confess( Template->error(), "\n" ); | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $engine->process(\$template, { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | features => $self->features, | ||||||||||||||||||||||||||||
| 97 | }, \$output ) | ||||||||||||||||||||||||||||
| 98 | || confess( Template->error(), "\n" ); | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | return $output; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub _get_template { | ||||||||||||||||||||||||||
|
Subroutine
_get_template: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 106 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | my $text; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return ($template, $blocks) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Test::Pcuke::Report::template and $Test::Pcuke::Report::blocks
MC/DC0%0/2
$Test::Pcuke::Report::template and $Test::Pcuke::Report::blocks
$Test::Pcuke::Report::template
$Test::Pcuke::Report::blocks
Truth table0%0/3
A and B
A= $Test::Pcuke::Report::templateB= $Test::Pcuke::Report::blocks
| |||||||||||||||||||||||||||||
| 111 | if $template && $blocks; | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||
| 114 | 0 | local $/; | |||||||||||||||||||||||||||
| 115 | 0 | $text = <DATA>; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | my @blocks = grep { $_ } | |||||||||||||||||||||||||||
| 119 | split( /(\[!!![^!]+!!!\])/, $text ); | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | while( @blocks ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | my ($header, $body) = (shift @blocks, shift @blocks); | |||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ( $header =~ /\[!!!\s+MAIN\s+!!!\]/ ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 124 | 0 | $template = $body; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | elsif ( $header =~ /\[!!!\s+BLOCK\s+(\w+)\s+!!!\]/ ) { | ||||||||||||||||||||||||||||
| 127 | 0 | $blocks->{$1} = $body; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||
| 130 | 0 | confess "unknown header: $header!"; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | return ($template, $blocks); | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 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 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>. 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::Report | ||||||||||||||||||||||||||||
| 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> | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | L<http://annocpan.org/dist//home/tut/bin/src/Test-Pcuke> | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | L<http://cpanratings.perl.org/d//home/tut/bin/src/Test-Pcuke> | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | L<http://search.cpan.org/dist//home/tut/bin/src/Test-Pcuke/> | ||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 192 | 3 | 1; # End of Test::Pcuke::Report | |||||||||||||||||||||||||||
| 193 | __DATA__ | ||||||||||||||||||||||||||||