lib/VSGDR/UnitTest/TestSet/Representation/XLS.pm

filter: Statementstmt 12.8% 40 / 311 Branchbran 0.0% 0 / 150 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 50.0% 13 / 26 Podpod 8.3% 1 / 12 totaltotal 10.1% 54 / 534 SCAR 86.6
CC
86
Cov
8%
readSpreadsheet
756.0
gatherTestSetConditions
272.0
gatherConditions
272.0
CRAP 5789.3
« lib/VSGDR/UnitTest/TestSet/Representation/NET.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Representation/XML.pm »
1 package VSGDR::UnitTest::TestSet::Representation::XLS;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 #our \$VERSION = '1.02';
9  
10  
11 1 ▶use parent qw(VSGDR::UnitTest::TestSet::Representation) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #TODO 1. Add support for test method attributes eg new vs2010 exceptions ala : -[ExpectedSqlException(MessageNumber = nnnnn, Severity = x, MatchFirstError = false, State = y)]
14  
15  
16 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Spreadsheet::WriteExcel;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Spreadsheet::ParseExcel;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use List::MoreUtils qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use VSGDR::UnitTest::TestSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use VSGDR::UnitTest::TestSet::Test;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27  
28 1 ▶use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30  
31 1 my $test_No ;
32 #our $wks_test ;
33 my $G_ln ;
34  
35  
36 sub _init {
37  
38 0 ▶ local $_ = undef ;
Subroutine _init: not called CC=3 SCAR=24.8
39  
40 0 my $self = shift ;
41 0 ▶ my $class = ref($self) || $self ;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
42 0 ▶ my $ref = shift or croak "no arg";
Branch: 1 branch
BranchTrueFalseTotal
my $ref = shift() or croak("no arg") 0 0 0
43  
44  
45 0 my ${Caller} = $$ref{NAMESPACE};
46
47 0 return ;
48
49 }
50  
51 ## ======================================================
52 ## could alias this *Here::blue = \$There::green;
53 ##let's not - harder to understand and will alias other member of the typeglobs
54 sub serialise {
55 0 ▶ my $self = shift or croak 'no self' ;
Subroutine serialise: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
56 0 return $self->writeSpreadsheet(@_) ;
57 }
58 ## ======================================================
59 sub deserialise {
60 0 ▶ my $self = shift or croak 'no self' ;
Subroutine deserialise: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
61 0 return $self->readSpreadsheet(@_) ;
62 }
63 ## ======================================================
64 # dummy implementations
65 ## ======================================================
66 sub code {
67 0 ▶ my $self = shift or croak 'no self' ;
Subroutine code: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
68 0 carp 'Dummy method - may you want serialise';
69 0 return "";
70 }
71 ## ======================================================
72 sub parse {
73 0 ▶ my $self = shift or croak 'no self' ;
Subroutine parse: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
74 0 carp 'Dummy method - may you want deserialise';
75 0 return "";
76 }
77 ## ======================================================
78  
79 sub readSpreadsheet {
80  
81 0 ▶ my $self = shift or croak 'no self' ;
Subroutine readSpreadsheet: not called CC=27 SCAR=66.3
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
82 0 ▶ my $file = shift or croak 'no file' ;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift() or croak("no file") 0 0 0
83
84 0 my $parser = Spreadsheet::ParseExcel->new();
85 0 my $workbook = $parser->Parse($file);
86  
87 0 ▶ my $worksheet = $workbook->worksheet('TestGlobals') or croak 'no TestGlobals worksheet' ;
Branch: 1 branch
BranchTrueFalseTotal
my $worksheet = $workbook->worksheet("TestGlobals") or croak("no TestGlobals worksheet") 0 0 0
88  
89 0 my %Globals = ( TESTNAMESPACE => $worksheet->get_cell(1,0)->value()
90 , TESTCLASS => $worksheet->get_cell(1,1)->value()
91 ) ;
92  
93 #warn Dumper %Globals ;
94
95 my $testSet = VSGDR::UnitTest::TestSet->new( { NAMESPACE => $Globals{TESTNAMESPACE}
96 , CLASSNAME => $Globals{TESTCLASS}
97 }
98 0 ) ;
99  
100  
101 0 my @header = $testSet->allConditionAttributeNames() ;
102 0 my %header_pos = () ;
103 0 ▶ for ( my $i = 0; $i <= $#header; $i++) { $header_pos{$header[$i]} = $i } ;
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#header) 0 0 0
104  
105 0 ▶ $worksheet = $workbook->worksheet('TestGlobalConditions') or croak 'no TestGlobalConditions worksheet' ;
Branch: 1 branch
BranchTrueFalseTotal
$worksheet = $workbook->worksheet("TestGlobalConditions") or croak("no TestGlobalConditions worksheet") 0 0 0
106  
107 #warn $worksheet->row_range() ;
108 0 my ($row_min,$row_max) = $worksheet->row_range();
109 0 ▶ my $testInitialiseAction = defined $worksheet->get_cell(0,1) ? $worksheet->get_cell(0,1)->value()
Branch: 1 branch
BranchTrueFalseTotal
defined $worksheet->get_cell(0, 1) ? : 0 0 0
110 : undef ;
111  
112 0 my %testSetActions ;
113 my @testConditions ;
114  
115 0 my $row = 1 ;
116 0 ▶ if ($testInitialiseAction) {
Branch: 1 branch
BranchTrueFalseTotal
if ($testInitialiseAction) { } 0 0 0
117 0 $testSetActions{'testInitializeAction'} = 1 ;
118 0 $testSet->initializeAction('testInitializeAction') ;
119 0 my $ra_testGlobalConditions = $self->gatherTestSetConditions($worksheet,'testInitializeAction',\@header,\%header_pos,$row,$row_max) ;
120 0 $testSet->initializeConditions($ra_testGlobalConditions);
121 }
122 else {
123 0 $testSet->initializeConditions([]);
124 }
125  
126 0 my $testCleanupAction = undef ;
127 0 ▶ for ( my $r = $row; $r <= $row_max; $r++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r <= $row_max) 0 0 0
128 0 ▶ if ( defined ($worksheet->get_cell($r,1)) and ($worksheet->get_cell($r,1)->value() eq 'testCleanupAction') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $worksheet->get_cell($r, 1) and $worksheet->get_cell($r, 1)->value eq "testCleanupAction") 0 0 0
Condition0%0/3
defined $worksheet->get_cell($r, 1) and $worksheet->get_cell($r, 1)->value eq "testCleanupAction"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $worksheet->get_cell($r, 1) and $worksheet->get_cell($r, 1)->value eq "testCleanupAction"
defined $worksheet->get_cell($r, 1) $worksheet->get_cell($r, 1)->value eq "testCleanupAction"
Truth table0%0/3
A and B
A= defined $worksheet->get_cell($r, 1)B= $worksheet->get_cell($r, 1)->value eq "testCleanupAction"
ABresult
0X0
100
111
129 0 $testCleanupAction = 1 ;
130 0 $row = $r+1 ;
131 0 last ;
132 }
133 }
134
135 0 ▶ if ($testCleanupAction) {
Branch: 1 branch
BranchTrueFalseTotal
if ($testCleanupAction) { } 0 0 0
136 0 $testSetActions{'testCleanupAction'} = 1 ;
137 0 $testSet->cleanupAction('testCleanupAction') ;
138 0 my $ra_testGlobalConditions = $self->gatherTestSetConditions($worksheet,'testCleanupAction',\@header,\%header_pos,$row,$row_max) ;
139 0 $testSet->cleanupConditions($ra_testGlobalConditions);
140 }
141 else {
142 0 $testSet->cleanupConditions([]);
143 }
144  
145 # $testSet->tests([]);
146  
147 0 my @testObjects = () ;
148
149 0 ▶ for ( my $wi = 2 ; $wi < $workbook->worksheet_count() ; $wi++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wi < $workbook->worksheet_count) 0 0 0
150 0 my $worksheet = $workbook->worksheet($wi) ;
151 0 my $testName = $worksheet->get_cell(0,1)->value() ;
152  
153 0 my ($row_min,$row_max) = $worksheet->row_range();
154  
155 0 my %TA = ( PretestAction => 'null'
156 , TestAction => 'null'
157 , PosttestAction => 'null'
158 ) ;
159  
160 0 my @preTestConditions = () ;
161 0 my @testConditions = () ;
162 0 my @postTestConditions = () ;
163  
164 0 my $row = 1 ;
165
166 0 my ($firstRow,$actionType) = $self->find_next_set($worksheet,$row,$row_max) ;
167 #warn Dumper ($firstRow,$actionType) ;
168 0 $row = $firstRow +1 ;
169 0 $TA{$actionType} = "${testName}_${actionType}" ;
170
171 0 ▶ if ( ${actionType} eq 'PretestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "PretestAction") 0 0 0
172 0 @preTestConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
173 }
174 0 ▶ if ( ${actionType} eq 'TestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "TestAction") 0 0 0
175 0 @testConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
176 }
177 0 ▶ if ( ${actionType} eq 'PosttestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "PosttestAction") 0 0 0
178 0 @postTestConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
179 }
180  
181 0 ($firstRow,$actionType) = $self->find_next_set($worksheet,$row,$row_max) ;
182
183 0 ▶ if ( defined $firstRow ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $firstRow) 0 0 0
184 #warn Dumper ($firstRow,$actionType) ;
185  
186 0 $row = $firstRow +1 ;
187 0 $TA{$actionType} = "${testName}_${actionType}" ;
188  
189 0 ▶ if ( ${actionType} eq 'PretestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "PretestAction") 0 0 0
190 0 @preTestConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
191 }
192 0 ▶ if ( ${actionType} eq 'TestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "TestAction") 0 0 0
193 0 @testConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
194 }
195 0 ▶ if ( ${actionType} eq 'PosttestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "PosttestAction") 0 0 0
196 0 @postTestConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
197 }
198 }
199 0 ($firstRow,$actionType) = $self->find_next_set($worksheet,$row,$row_max) ;
200 0 ▶ if ( defined $firstRow ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $firstRow) 0 0 0
201 #warn Dumper ($firstRow,$actionType) ;
202  
203 0 $row = $firstRow +1 ;
204 0 $TA{$actionType} = "${testName}_${actionType}" ;
205  
206 0 ▶ if ( ${actionType} eq 'PretestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "PretestAction") 0 0 0
207 0 @preTestConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
208 }
209 0 ▶ if ( ${actionType} eq 'TestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "TestAction") 0 0 0
210 0 @testConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
211 }
212 0 ▶ if ( ${actionType} eq 'PosttestAction' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actionType eq "PosttestAction") 0 0 0
213 0 @postTestConditions = $self->gatherConditions($worksheet,"${testName}_${actionType}",\@header,\%header_pos,$row,$row_max) ;
214 }
215 }
216  
217 my $testObject = VSGDR::UnitTest::TestSet::Test->new( { TESTNAME => $testName
218 , TESTACTIONDATANAME => "${testName}Data"
219 , PRETESTACTION => $TA{PretestAction}
220 , TESTACTION => $TA{TestAction}
221 , POSTTESTACTION => $TA{PosttestAction}
222 0 } ) ;
223
224 0 $testObject->preTest_conditions( \@preTestConditions ) ;
225 0 $testObject->test_conditions( \@testConditions ) ;
226 0 $testObject->postTest_conditions( \@postTestConditions ) ;
227  
228 0 ▶ if ( scalar(@preTestConditions)) { $testSetActions{$testObject->testName() . "_PretestAction"} = 1 ; } ;
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @preTestConditions) 0 0 0
229 0 ▶ if ( scalar(@testConditions)) { $testSetActions{$testObject->testName() . "_TestAction"} = 1 ; } ;
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @testConditions) 0 0 0
230 0 ▶ if ( scalar(@postTestConditions)) { $testSetActions{$testObject->testName() . "_PosttestAction"} = 1 ; } ;
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @postTestConditions) 0 0 0
231  
232 0 push @testObjects, $testObject ;
233  
234 }
235  
236  
237 0 $testSet->tests(\@testObjects) ;
238 # $testSet->actions(\%testSetActions) ;
239 #warn Dumper $testSet ;
240 0 return $testSet;
241 }
242  
243  
244 sub find_next_set {
245 0 ▶ my $self = shift or croak 'no self' ;
Subroutine find_next_set: not called CC=8 SCAR=42.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
246 0 ▶ my $wks = shift or croak 'no worksheet' ;
Branch: 1 branch
BranchTrueFalseTotal
my $wks = shift() or croak("no worksheet") 0 0 0
247 0 ▶ my $row = shift or croak 'no start row' ;
Branch: 1 branch
BranchTrueFalseTotal
my $row = shift() or croak("no start row") 0 0 0
248 0 ▶ my $row_max = shift or croak 'no max row' ;
Branch: 1 branch
BranchTrueFalseTotal
my $row_max = shift() or croak("no max row") 0 0 0
249  
250 0 my $retRow = undef ;
251 0 my $retVal = undef ;
252  
253 0 ▶ for (my $r = $row; $r <= $row_max; $r++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r <= $row_max) 0 0 0
254 0 ▶ if ( defined $wks->get_cell($r,1) and $wks->get_cell($r,1)->value() =~ m{^(?:Pre|Post|)TestAction}ix ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wks->get_cell($r, 1) and $wks->get_cell($r, 1)->value =~ /^(?:Pre|Post|)TestAction/xi) 0 0 0
Condition0%0/3
defined $wks->get_cell($r, 1) and $wks->get_cell($r, 1)->value =~ /^(?:Pre|Post|)TestAction/xi
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wks->get_cell($r, 1) and $wks->get_cell($r, 1)->value =~ /^(?:Pre|Post|)TestAction/xi
defined $wks->get_cell($r, 1) $wks->get_cell($r, 1)->value =~ /^(?:Pre|Post|)TestAction/xi
Truth table0%0/3
A and B
A= defined $wks->get_cell($r, 1)B= $wks->get_cell($r, 1)->value =~ /^(?:Pre|Post|)TestAction/xi
ABresult
0X0
100
111
255 0 $retRow = $r ;
256 0 $retVal = $wks->get_cell($r,1)->value() ;
257 0 last;
258 }
259 }
260  
261 0 return ($retRow,$retVal) ;
262 }
263  
264 sub gatherTestSetConditions {
265  
266 0 ▶ my $self = shift or croak 'no self' ;
Subroutine gatherTestSetConditions: not called CC=16 SCAR=56.1
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
267 0 ▶ my $wks = shift or croak 'no worksheet' ;
Branch: 1 branch
BranchTrueFalseTotal
my $wks = shift() or croak("no worksheet") 0 0 0
268 0 ▶ my $testAction = shift or croak 'no action';
Branch: 1 branch
BranchTrueFalseTotal
my $testAction = shift() or croak("no action") 0 0 0
269 0 ▶ my $ra_header = shift or croak 'no headers' ;
Branch: 1 branch
BranchTrueFalseTotal
my $ra_header = shift() or croak("no headers") 0 0 0
270 0 ▶ my $rh_header_cols = shift or croak 'no header cols' ;
Branch: 1 branch
BranchTrueFalseTotal
my $rh_header_cols = shift() or croak("no header cols") 0 0 0
271 0 ▶ my $row = shift or croak 'no start row' ;
Branch: 1 branch
BranchTrueFalseTotal
my $row = shift() or croak("no start row") 0 0 0
272 0 ▶ my $row_max = shift or croak 'no max row' ;
Branch: 1 branch
BranchTrueFalseTotal
my $row_max = shift() or croak("no max row") 0 0 0
273  
274 0 my @testGlobalConditions = () ;
275  
276 0 my $TYPECOL = 2 ;
277 0 ▶ for (my $r = $row; $r <= $row_max; $r++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r <= $row_max) 0 0 0
278  
279 0 ▶ last if defined $wks->get_cell($r,0) ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wks->get_cell($r, 0) 0 0 0
280 0 ▶ last if ( defined $wks->get_cell($r,0) and $wks->get_cell($r,0)->value() ) ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wks->get_cell($r, 0) and $wks->get_cell($r, 0)->value 0 0 0
Condition0%0/3
defined $wks->get_cell($r, 0) and $wks->get_cell($r, 0)->value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wks->get_cell($r, 0) and $wks->get_cell($r, 0)->value
defined $wks->get_cell($r, 0) $wks->get_cell($r, 0)->value
Truth table0%0/3
A and B
A= defined $wks->get_cell($r, 0)B= $wks->get_cell($r, 0)->value
ABresult
0X0
100
111
281  
282 0 ▶ last if not defined $wks->get_cell($r,$TYPECOL) ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $wks->get_cell($r, $TYPECOL) 0 0 0
283 0 ▶ last if ( defined $wks->get_cell($r,$TYPECOL) and $wks->get_cell($r,$TYPECOL)->value() eq '' ) ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wks->get_cell($r, $TYPECOL) and $wks->get_cell($r, $TYPECOL)->value eq "" 0 0 0
Condition0%0/3
defined $wks->get_cell($r, $TYPECOL) and $wks->get_cell($r, $TYPECOL)->value eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wks->get_cell($r, $TYPECOL) and $wks->get_cell($r, $TYPECOL)->value eq ""
defined $wks->get_cell($r, $TYPECOL) $wks->get_cell($r, $TYPECOL)->value eq ""
Truth table0%0/3
A and B
A= defined $wks->get_cell($r, $TYPECOL)B= $wks->get_cell($r, $TYPECOL)->value eq ""
ABresult
0X0
100
111
284  
285 0 my $testconditiontype = $wks->get_cell($r,$TYPECOL)->value() ;
286
287 0 ▶ my @populatedColumns = map { $_ - $TYPECOL } grep { defined $wks->get_cell($r,$_) and $wks->get_cell($r,$_)->value() ne '' } ( $TYPECOL+1 .. $TYPECOL + scalar(@{$ra_header}) ) ;
Branch: 1 branch
BranchTrueFalseTotal
defined $wks->get_cell($r, $_) and $wks->get_cell($r, $_)->value ne "" 0 0 0
288 0 my @populatedVals = map { $wks->get_cell($r,$_ + $TYPECOL)->value() } @populatedColumns ;
289  
290 0 my @populatedColumnsHeaders = map { $ra_header->[$_] } @populatedColumns ;
291 0 my @populatedColumnsHeadersHASH = map { uc "CONDITION${_}" } @populatedColumnsHeaders ;
292  
293 0 my @constructor = zip( @populatedColumnsHeadersHASH,@populatedVals );
294 0 my %constructor = @constructor ;
295  
296 0 $constructor{TESTCONDITIONTYPE} = $testconditiontype ;
297 0 $constructor{CONDITIONTESTACTIONNAME} = $testAction ;
298
299 0 my $testConditionObject = VSGDR::UnitTest::TestSet::Test::TestCondition->make(\%constructor) ;
300 0 push @testGlobalConditions, $testConditionObject ;
301 }
302  
303 0 return (\@testGlobalConditions) ;
304 }
305  
306  
307 sub gatherConditions {
308  
309 0 ▶ my $self = shift or croak 'no self' ;
Subroutine gatherConditions: not called CC=16 SCAR=56.1
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
310 0 ▶ my $wks = shift or croak 'no worksheet' ;
Branch: 1 branch
BranchTrueFalseTotal
my $wks = shift() or croak("no worksheet") 0 0 0
311 0 ▶ my $testAction = shift or croak 'no action';
Branch: 1 branch
BranchTrueFalseTotal
my $testAction = shift() or croak("no action") 0 0 0
312 0 ▶ my $ra_header = shift or croak 'no headers' ;
Branch: 1 branch
BranchTrueFalseTotal
my $ra_header = shift() or croak("no headers") 0 0 0
313 0 ▶ my $rh_header_cols = shift or croak 'no header cols' ;
Branch: 1 branch
BranchTrueFalseTotal
my $rh_header_cols = shift() or croak("no header cols") 0 0 0
314 0 ▶ my $row = shift or croak 'no start row' ;
Branch: 1 branch
BranchTrueFalseTotal
my $row = shift() or croak("no start row") 0 0 0
315 0 ▶ my $row_max = shift or croak 'no max row' ;
Branch: 1 branch
BranchTrueFalseTotal
my $row_max = shift() or croak("no max row") 0 0 0
316  
317 0 my @testGlobalConditions = () ;
318  
319 0 my $TYPECOL = 2 ;
320 0 ▶ for (my $r = $row; $r <= $row_max; $r++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r <= $row_max) 0 0 0
321  
322 0 ▶ last if defined $wks->get_cell($r,1) ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wks->get_cell($r, 1) 0 0 0
323 0 ▶ last if ( defined $wks->get_cell($r,1) and $wks->get_cell($r,1)->value() ) ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wks->get_cell($r, 1) and $wks->get_cell($r, 1)->value 0 0 0
Condition0%0/3
defined $wks->get_cell($r, 1) and $wks->get_cell($r, 1)->value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wks->get_cell($r, 1) and $wks->get_cell($r, 1)->value
defined $wks->get_cell($r, 1) $wks->get_cell($r, 1)->value
Truth table0%0/3
A and B
A= defined $wks->get_cell($r, 1)B= $wks->get_cell($r, 1)->value
ABresult
0X0
100
111
324  
325 0 ▶ last if not defined $wks->get_cell($r,$TYPECOL) ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $wks->get_cell($r, $TYPECOL) 0 0 0
326 0 ▶ last if ( defined $wks->get_cell($r,$TYPECOL) and $wks->get_cell($r,$TYPECOL)->value() eq '' ) ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wks->get_cell($r, $TYPECOL) and $wks->get_cell($r, $TYPECOL)->value eq "" 0 0 0
Condition0%0/3
defined $wks->get_cell($r, $TYPECOL) and $wks->get_cell($r, $TYPECOL)->value eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wks->get_cell($r, $TYPECOL) and $wks->get_cell($r, $TYPECOL)->value eq ""
defined $wks->get_cell($r, $TYPECOL) $wks->get_cell($r, $TYPECOL)->value eq ""
Truth table0%0/3
A and B
A= defined $wks->get_cell($r, $TYPECOL)B= $wks->get_cell($r, $TYPECOL)->value eq ""
ABresult
0X0
100
111
327  
328 0 my $testconditiontype = $wks->get_cell($r,$TYPECOL)->value() ;
329
330 0 ▶ my @populatedColumns = map { $_ - $TYPECOL } grep { defined $wks->get_cell($r,$_) and $wks->get_cell($r,$_)->value() ne '' } ( $TYPECOL+1 .. $TYPECOL + scalar(@{$ra_header}) ) ;
Branch: 1 branch
BranchTrueFalseTotal
defined $wks->get_cell($r, $_) and $wks->get_cell($r, $_)->value ne "" 0 0 0
331 0 my @populatedVals = map { $wks->get_cell($r,$_ + $TYPECOL)->value() } @populatedColumns ;
332  
333 0 my @populatedColumnsHeaders = map { $ra_header->[$_] } @populatedColumns ;
334 0 my @populatedColumnsHeadersHASH = map { uc "CONDITION${_}" } @populatedColumnsHeaders ;
335  
336 0 my @constructor = zip( @populatedColumnsHeadersHASH,@populatedVals );
337 0 my %constructor = @constructor ;
338  
339 0 $constructor{TESTCONDITIONTYPE} = $testconditiontype ;
340 0 $constructor{CONDITIONTESTACTIONNAME} = $testAction ;
341
342 #warn Dumper %constructor ;
343  
344 0 my $testConditionObject = VSGDR::UnitTest::TestSet::Test::TestCondition->make(\%constructor) ;
345 0 push @testGlobalConditions, $testConditionObject ;
346 }
347  
348 0 return (@testGlobalConditions) ;
349 }
350  
351  
352 sub representationType {
353 0 ▶ my $self = shift;
Subroutine representationType: not called CC=1 SCAR=6.9
Pod undocumented
354 0 return 'XLS' ;
355 }
356  
357  
358 sub writeSpreadsheet {
359 0 ▶ my $self = shift or croak 'no self' ;
Subroutine writeSpreadsheet: not called CC=10 SCAR=47.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
360 0 ▶ my $filename = shift or croak 'no file' ;
Branch: 1 branch
BranchTrueFalseTotal
my $filename = shift() or croak("no file") 0 0 0
361 0 ▶ my $testSet = shift or croak 'no test' ;
Branch: 1 branch
BranchTrueFalseTotal
my $testSet = shift() or croak("no test") 0 0 0
362  
363 0 my $colOffset = 2 ;
364  
365 0 my @header = $testSet->allConditionAttributeNames() ;
366 0 my %header_pos = () ;
367 0 ▶ for ( my $i = 0; $i <= $#header; $i++) { $header_pos{$header[$i]} = $i } ;
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#header) 0 0 0
368  
369 0 my $workbook = Spreadsheet::WriteExcel->new(${filename});
370  
371 0 my $format1 = $workbook->add_format();
372 0 $format1->set_bold();
373  
374  
375 0 my $wks_globals = $workbook->add_worksheet('TestGlobals');
376 0 $wks_globals->write_row(0,0,['TestNameSpace','TestClass'],$format1) ;
377 0 $wks_globals->write_row(1,0,[ $testSet->nameSpace()
378 , $testSet->className()
379 ]
380 ) ;
381  
382 0 my $wks_globalconditions = $workbook->add_worksheet('TestGlobalConditions');
383
384 0 $G_ln = 0 ;
385 0 $wks_globalconditions->write_row($G_ln, 0, ['TestInitializeAction'],$format1);
386 0 $wks_globalconditions->write_row($G_ln, 1, [$testSet->initializeAction()]);
387 0 $wks_globalconditions->write_row($G_ln, $colOffset, \@header,$format1);
388  
389 0 ▶ if ( $testSet->initializeAction() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($testSet->initializeAction) 0 0 0
390 0 $G_ln++;
391 0 my $ra_Conditions = $testSet->initializeConditions();
392 0 $self->printConditions( $wks_globalconditions,\@header, \%header_pos, $ra_Conditions) ;
393 }
394  
395 0 $G_ln++;$G_ln++;
396  
397 0 $wks_globalconditions->write_row($G_ln, 0, ['TestCleanupAction'],$format1);
398 0 $wks_globalconditions->write_row($G_ln, 1, [$testSet->cleanupAction()]);
399 0 $wks_globalconditions->write_row($G_ln, $colOffset, \@header,$format1);
400 0 ▶ if ( $testSet->cleanupAction() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($testSet->cleanupAction) 0 0 0
401 0 $G_ln++;
402 0 my $ra_Conditions = $testSet->cleanupConditions();
403 0 $self->printConditions( $wks_globalconditions,\@header, \%header_pos, $ra_Conditions) ;
404 }
405  
406  
407 0 my $ra_tests = $testSet->tests() ;
408 0 my $wks_test = undef ;
409
410 0 $test_No = 0 ;
411 0 for my $test (@$ra_tests) {
412 0 $test_No++ ;
413 0 $wks_test = $workbook->add_worksheet("Test ${test_No}");
414 0 $G_ln = 0 ;
415 0 $wks_test->write_row($G_ln, 0, [ 'Test Name '],$format1);
416 0 $wks_test->write_row($G_ln, 1, [ $test->testName() ]);
417 0 my $ra_Conditions = undef ;
418 0 ▶ if ( $test->preTestAction() ne 'null' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($test->preTestAction ne "null") 0 0 0
419 0 $wks_test->write_row($G_ln, $colOffset, \@header,$format1);
420 0 $G_ln++;
421 0 $wks_test->write_row($G_ln, 1, ['PretestAction'],$format1);
422 0 $G_ln++;
423 0 $ra_Conditions = $test->preTest_conditions();
424 0 $self->printConditions( $wks_test,\@header, \%header_pos, $ra_Conditions) ;
425 }
426  
427 0 $G_ln++;
428 0 $wks_test->write_row($G_ln, $colOffset, \@header,$format1);
429 0 $G_ln++;
430 0 $wks_test->write_row($G_ln, 1, ['TestAction'],$format1);
431 0 $G_ln++;
432 0 $ra_Conditions = $test->test_conditions();
433 0 $self->printConditions( $wks_test,\@header, \%header_pos, $ra_Conditions) ;
434 0 $G_ln++;
435  
436 0 ▶ if ( $test->postTestAction() ne 'null' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($test->postTestAction ne "null") 0 0 0
437 0 $wks_test->write_row($G_ln, $colOffset, \@header,$format1);
438 0 $G_ln++;
439 0 $wks_test->write_row($G_ln, 1, ['PosttestAction'],$format1);
440 0 $G_ln++;
441 0 $ra_Conditions = $test->postTest_conditions();
442 0 $self->printConditions( $wks_test,\@header, \%header_pos, $ra_Conditions) ;
443 0 $G_ln++;
444 }
445 }
446
447 0 $workbook->close();
448 0 return "" ; #$workbook ;
449  
450 }
451  
452  
453 sub printConditions {
454
455 0 ▶ local $_ = undef ;
Subroutine printConditions: not called CC=8 SCAR=42.8
Pod undocumented
456  
457
458 0 ▶ my $self = shift or croak 'no self' ;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
459 0 ▶ my $wks = shift or croak 'no worksheet';
Branch: 1 branch
BranchTrueFalseTotal
my $wks = shift() or croak("no worksheet") 0 0 0
460 0 ▶ my $ra_header = shift or croak 'no header' ;
Branch: 1 branch
BranchTrueFalseTotal
my $ra_header = shift() or croak("no header") 0 0 0
461 0 ▶ my $rh_header_pos = shift or croak 'no header' ;
Branch: 1 branch
BranchTrueFalseTotal
my $rh_header_pos = shift() or croak("no header") 0 0 0
462 0 ▶ my $ra_Conditions = shift or croak 'no conditions' ;
Branch: 1 branch
BranchTrueFalseTotal
my $ra_Conditions = shift() or croak("no conditions") 0 0 0
463
464 0 my %conditionVals = map { $_ => undef } @{$ra_header} ;
465  
466 0 my $colOffset = 2 ;
467
468 0 for my $condition (@$ra_Conditions) {
469 0 my @attrs = $condition->testConditionAttributes();
470 0 my @attrvals = () ;
471 #warn Dumper @attrs ;
472 0 for my $attr ( grep { $_ !~ m{^conditionTestActionName$}x } @attrs ) {
473 0 ( my $fixedName = $attr ) =~ s{^condition}{}ix;
474 0 $conditionVals{$fixedName} = $condition->${attr}() ;
475 0 $attrvals[$rh_header_pos->{$fixedName}] = $condition->${attr}() ;
476 }
477 0 $attrvals[$rh_header_pos->{'Type'}] = $condition->testConditionType() ;
478 #warn "hello\n";
479 #warn $condition->testConditionType();
480 #warn Dumper @attrvals;
481 0 $wks->write_row($G_ln, $colOffset, \@attrvals);
482 0 $G_ln++;
483 }
484
485 0 return ;
486 }
487  
488 0 ▶sub flatten { return map { @$_} @_ } ;
Subroutine flatten: not called CC=1 SCAR=6.9
Pod undocumented
489  
490 1 1 ;
491  
492 __DATA__
« lib/VSGDR/UnitTest/TestSet/Representation/NET.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Representation/XML.pm »