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

View File

@@ -1,5 +1,3 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
function Test-APIReadXls { function Test-APIReadXls {
param( param(
[parameter(Mandatory)] [parameter(Mandatory)]
@@ -7,7 +5,7 @@ function Test-APIReadXls {
$WorksheetName = 'Sheet1' $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 $records = Import-Excel $XlFilename
@@ -37,7 +35,6 @@ function Test-APIReadXls {
"@ "@
}) })
@" @"
Describe "Tests from $($XlFilename) in $($WorksheetName)" { Describe "Tests from $($XlFilename) in $($WorksheetName)" {
$($blocks) $($blocks)

Binary file not shown.