package Test::AutomationFramework; use 5.012003; use strict; use warnings; use Date::Manip; use File::Path; use Test::More; use Getopt::Long; use File::Copy; use File::Find; use Cwd; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( help processTCs processTC processProperty genDriver ); our $VERSION = '0.057.0'; # local run version and /o IIS my %tsProperty;my $propertyOp=''; my $regression=0; my $help=0; my $sleep4Display = 0; my $notUsegetTCName= 0; my $scriptName = $0; $scriptName =~ s/\\/\\\\/g; my $web_ui_title="Test Automation Framework"; my $tcNamePattern = "TC*"; my $tsProperty = 'tsProperty.txt'; my $reportHtml = 'index.htm'; my $reportHtml1 = '_tcReport_.html'; my $reportHistoryHtml = '_tcReportHistory_.html'; my $SvrDrive = 'c:/_TAF'; my $SvrProjName = '_testSuit_'; my $SvrTCName = '_testCase_'; my $SvrTCNamePattern = "*"; my $SvrPropNamePattern = '.*'; my $SvrPropValuePattern = ".*"; my $SvrTCNameExecPattern = ".".$SvrTCNamePattern; my $tcOp= 'list'; my $pr2Screen = 1; my $SvrLogDir = ''.$SvrProjName.''; my $url = 'file:///'.$SvrDrive; # my $url = "http://10.24.2.66/TAF"; # Local or IIS sub new { my $package = shift; return bless({}, $package); } sub tcLoop { if ($pr2Screen == 1) {print "Processing ......\n" ; } else { print "";} # &tcPre(); my $returnValue = &tcMain(); &tcPost(); &tcPre(); my $returnValue = &tcMain_(); &tcPost(); if ($pr2Screen==1) {print " - Completed -"; } else { print "";} return $returnValue; } sub tcPre { ##################### PrePRocessor ##################### &createFile($SvrDrive.'\\'.$SvrProjName.'\\'.$reportHtml1,""); &createFile($SvrDrive.'\\'.$SvrProjName.'\\'.$reportHistoryHtml,""); &appendtoFile($SvrDrive.'\\'.$SvrProjName.'\\'.$reportHistoryHtml,"
\n");
########################################################
}
sub tcMain {
##################### Test Execution ###################
my $returnValue ='';
foreach my $eachTC (<$SvrDrive/$SvrProjName/$SvrTCNamePattern>) { # TC Filter
if ( &matchProperty ($SvrPropNamePattern, $SvrPropValuePattern, $eachTC) =~ /true/i) { # Property Filter
$eachTC = &getRoot($eachTC);
if ($propertyOp !~ /^\s*$/) { printf "%20s\n", &processProperty($eachTC, $propertyOp); } # PropertyManagement
elsif (($tcOp !~ /^\s*$/)&&(&getRoot($eachTC)=~/$SvrTCNameExecPattern/)) {
&updateWeb($eachTC,1);
$returnValue = $returnValue. &processTC("","$tcOp=$eachTC",$pr2Screen)."\n"; # TC Execution
sleep $sleep4Display;
&updateWeb($eachTC,0);
}
&logTC($eachTC); # TC Logging
# &reportTC($eachTC,"","lastValue"); # TC Reporting -> _tcReport_.html
&reportTCHistory($eachTC); # TC ReporHistory -> _tcReportHistory_.html
}
}
return $returnValue;
########################################################
}
sub tcMain_ { $notUsegetTCName= 1; find(\&recursiveSearchtcMain, $SvrDrive); }
sub recursiveSearchtcMain() {
my $returnValue ='';
if ($SvrTCNamePattern eq '*') { $SvrTCNamePattern = '.*';}
if (($File::Find::name =~ /tc.pl/) && ($File::Find::name =~ /$SvrDrive\/$SvrProjName/i) && ($File::Find::name =~ /$SvrTCNamePattern/i)) # TC Filter
{ my $eachTC = &getRoot($File::Find::name);
$SvrTCName = &getDir($File::Find::name);
$eachTC = &getRoot($eachTC);
if ($propertyOp !~ /^\s*$/) { printf "%20s\n", &processProperty($eachTC, $propertyOp); } # PropertyManagement
elsif (($tcOp !~ /^\s*$/)&&($SvrTCName =~/$SvrTCNameExecPattern/)) {
&updateWeb(&getDir($File::Find::name),1);
$returnValue = $returnValue. &processTC("","$tcOp=$eachTC",$pr2Screen)."\n"; # TC Execution
sleep $sleep4Display;
&updateWeb(&getDir($File::Find::name),0);
}
&logTC($eachTC); # TC Logging
# &reportTC($eachTC,"","lastValue"); # TC Reporting -> _tcReport_.html
&reportTCHistory($eachTC); # TC ReporHistory -> _tcReportHistory_.html
#} # Property Filter
} # TC Filter
}
sub tcPost {
##################### Post PRocessor ###################
&appendtoFile($SvrDrive.'\\'.$SvrProjName.'\\'.$reportHistoryHtml,"\n");
&prHtml1();
&appendtoFileFile($SvrDrive.'\\'.$SvrProjName.'\\'.$reportHtml1, $SvrDrive.'\\'.$SvrProjName.'\\'.$reportHtml);
&prHtml2();
########################################################
}
sub generateRootIndex {
open INDEX, ">$SvrDrive/index.htm";
print INDEX<Automated Test Suites on 10.24.2.66