cEPRSRunXVT.psm1
[DscResource()] Class cEPRSRunBVT { [DscProperty(Key)] [String] $ExecutableFullPath [DscProperty(Mandatory = $true)] [String] $TestDllPath #Path to test dll [DscProperty(Mandatory = $true)] [String] $TestDllName [DscProperty(Mandatory = $true)] [String] $ApplicationName [cEPRSRunBVT]Get() { $configData = @{ ExecutableFullPath = "$($this.ExecutableFullPath)" TestDllPath = "$($this.TestDllPath)" TestDllName = "$($this.TestDllName)" ApplicationName = "$($this.ApplicationName)" } return $configData } [bool] Test() { $result = $true if(Test-Path "$($this.ExecutableFullPath)") { if(Test-Path "$($this.TestDllPath)\$($this.TestDllName)") { $result = $false } else { return $true } } else { $result = $true } return $result } Set() { Set-Location "$($this.TestDllPath)" if(!(Test-Path "$($this.TestDllPath)\TestResults")) { md -Path "$($this.TestDllPath)\TestResults" -ea SilentlyContinue } if(Test-Path "$($this.TestDllPath)\TestResults\TestSuite.trx") { Remove-Item "$($this.TestDllPath)\TestResults\TestSuite.trx" } & "$($this.ExecutableFullPath)" /resultsfile:"$($this.TestDllPath)\$($this.ApplicationName).trx" /testcontainer:"$($this.TestDllPath)\$($this.TestDllName)" [xml]$testResults = Get-Content "$($this.TestDllPath)\TestResults\TestSuite.trx" foreach($summary in $testResults.TestRun.ResultSummary.Counters) { [int]$Script:failedTests=$summary.failed [int]$Script:passedTests=$summary.passed [int]$Script:errorTests=$summary.error [int]$Script:timedOutTests=$summary.timeout } if(($Script:failedTests -gt 0) -or ($Script:failedTests -gt 0) -or ($Script:failedTests -gt 0)) { $statusBvt=1 Write-Verbose "ERROR: BVT execution failed. Passed: $Script:passedTests. Failed: $Script:failedTests. Error: $Script:errorTests. Timedout:$Script:timedOutTests. Please check folder $($this.TestDllPath) for execution summary and log files." throw "ERROR: $Script:TestTypeInUpper execution failed. Passed: $Script:passedTests. Failed: $Script:failedTests. Error:$Script:errorTests. Timedout: $Script:timedOutTests. Please check folder $($this.TestDllPath) for execution summary and log files." } else { $statusBvt=0 Write-Verbose "SUCCESS: $Script:TestTypeInUpper execution succeeded. Passed: $Script:passedTests. Failed: $Script:failedTests. Error: $Script:errorTests. Timedout: $Script:timedOutTests. Please check folder $($this.TestDllPath) for execution summary and log files." } } } [DscResource()] Class cEPRSRunEVT { [DscProperty(Key)] [String] $EVTExecutablePath #Path to test dll [DscProperty(Mandatory = $true)] [String] $EVTExecutableName [DscProperty(Mandatory=$true)] [String] $EVTConfigName [DscProperty(Mandatory=$true)] [String] $EVTManifestName [cEPRSRunEVT] Get() { $configData = @{ EVTExecutablePath = "$($this.EVTExecutablePath)" EVTExecutableName = "$($this.EVTExecutableName)" EVTConfigName = "$($this.EVTConfigName)" EVTManifestName = "$($this.EVTManifestName)" } return $configData } [bool] Test() { return $false } Set() { Set-Location "$($this.EVTExecutablePath)" & "$($this.EVTExecutablePath)\$($this.EVTExecutableName)" "$($this.EVTExecutablePath)\$($this.EVTConfigName)" "$($this.EVTExecutablePath)\$($this.EVTManifestName)" $xml1=New-Object XML $xml1.Load("$($this.EVTExecutablePath)\EvtOutputSummary.xml") $Status=$xml1.GetElementsByTagName("Status") if($Status[0].InnerXml -eq "Success") { $statusEvt=0 Write-Verbose "SUCCESS: EVT execution succeeded. Please check folder $($this.EVTExecutablePath) for execution summary and log files." } else { $statusEvt=1 Write-Verbose "ERROR: EVT execution failed. Please check folder $($this.EVTExecutablePath) for execution summary and log files." throw "ERROR: EVT execution failed. Please check folder $($this.EVTExecutablePath) for execution summary and log files." } } } [DscResource()] Class cEPRSRunIVT { [DscProperty(Key)] [String] $IVTExecutablePath #Path to test dll [DscProperty(Mandatory = $true)] [String] $IVTExecutableName [DscProperty(Mandatory=$true)] [String] $IVTConfigName [DscProperty(Mandatory=$true)] [String] $IVTManifestName [cEPRSRunIVT] Get() { $configData = @{ IVTExecutablePath = "$($this.IVTExecutablePath)" IVTExecutableName = "$($this.IVTExecutableName)" IVTConfigName = "$($this.IVTConfigName)" IVTManifestName = "$($this.IVTManifestName)" } return $configData } [bool] Test() { return $false } Set() { Set-Location "$($this.IVTExecutablePath)" & "$($this.IVTExecutablePath)\$($this.IVTExecutableName)" "$($this.IVTExecutablePath)\$($this.IVTConfigName)" "$($this.IVTExecutablePath)\$($this.IVTManifestName)" $xml1=New-Object XML $xml1.Load("$($this.IVTExecutablePath)\IVTOutputSummary.xml") $Status=$xml1.GetElementsByTagName("Status") if($Status[0].InnerXml -eq "Success") { $statusIVT=0 Write-Verbose "SUCCESS: IVT execution succeeded. Please check folder $($this.IVTExecutablePath) for execution summary and log files." } else { $statusIVT=1 Write-Verbose "ERROR: IVT execution failed. Please check folder $($this.IVTExecutablePath) for execution summary and log files." throw "ERROR: IVT execution failed. Please check folder $($this.IVTExecutablePath) for execution summary and log files." } } } |