This commit is contained in:
dfinke
2019-02-18 13:51:50 -05:00
parent 2949ecc173
commit 438be760f7
3 changed files with 23 additions and 34 deletions

View File

@@ -1,40 +1,32 @@
function Show-PesterResults {
$xlfilename=".\test.xlsx"
rm $xlfilename -ErrorAction Ignore
$xlfilename = ".\test.xlsx"
Remove-Item $xlfilename -ErrorAction Ignore
$ConditionalText = @()
$ConditionalText += New-ConditionalText -Range "Result" -Text failed -BackgroundColor red -ConditionalTextColor black
$ConditionalText += New-ConditionalText -Range "Result" -Text passed -BackgroundColor green -ConditionalTextColor black
$ConditionalText += New-ConditionalText -Range "Result" -Text pending -BackgroundColor gray -ConditionalTextColor black
$xlParams = @{
Path=$xlfilename
WorkSheetname = 'PesterTests'
ConditionalText=$ConditionalText
PivotRows = 'Description'
PivotColumns = 'Result'
PivotData = @{'Result'='Count'}
IncludePivotTable = $true
#IncludePivotChart = $true
#NoLegend = $true
#ShowPercent = $true
#ShowCategory = $true
AutoSize = $true
AutoNameRange = $true
AutoFilter = $true
Show = $true
Path = $xlfilename
WorkSheetname = 'PesterTests'
ConditionalText = $ConditionalText
PivotRows = 'Result', 'Name'
PivotData = @{'Result' = 'Count'}
IncludePivotTable = $true
AutoSize = $true
AutoNameRange = $true
AutoFilter = $true
Show = $true
}
$(foreach($result in (Invoke-Pester -PassThru -Show None).TestResult) {
[PSCustomObject]@{
Description = $result.Describe
Name = $result.Name
#Time = $result.Time
Result = $result.Result
Messge = $result.FailureMessage
StackTrace = $result.StackTrace
}
}) | Sort Description | Export-Excel @xlParams
$(foreach ($result in (Invoke-Pester -PassThru -Show None).TestResult) {
[PSCustomObject]@{
Description = $result.Describe
Name = $result.Name
Result = $result.Result
Messge = $result.FailureMessage
StackTrace = $result.StackTrace
}
}) | Sort-Object Description | Export-Excel @xlParams
}

View File

@@ -1,5 +1,3 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
function Test-APIReadXls {
param(
[parameter(Mandatory)]
@@ -7,7 +5,7 @@ function Test-APIReadXls {
$WorksheetName = 'Sheet1'
)
$testFileName = "{0}.tests.ps1" -f (get-date).ToString("yyyyMMddHHmmss.fff")
$testFileName = "{0}.tests.ps1" -f (get-date).ToString("yyyyMMddHHmmss")
$records = Import-Excel $XlFilename
@@ -37,7 +35,6 @@ function Test-APIReadXls {
"@
})
@"
Describe "Tests from $($XlFilename) in $($WorksheetName)" {
$($blocks)

Binary file not shown.