Fix test not working with single digit dates.

This commit is contained in:
jhoneill
2019-12-30 00:34:40 +00:00
parent 7bfb28d10f
commit e65210e378
2 changed files with 53 additions and 45 deletions

View File

@@ -1,5 +1,4 @@

[CmdletBinding(DefaultParameterSetName = 'Default')]
param(
[Parameter(Position=0)]
@@ -30,10 +29,10 @@ param(
[string[]]$ExcludeTag,
[Parameter(ParameterSetName='Default')]
[Switch]$Strict,
[String]$WorkSheetName = 'PesterResults',
[switch]$Strict,
[string]$WorkSheetName = 'PesterResults',
[switch]$append,
[switch]$Show
)
@@ -45,6 +44,7 @@ if ($InvokePesterParams['Show'] ) {}
if ($InvokePesterParams['XLFile']) {$InvokePesterParams.Remove('XLFile')}
else {$XLFile = $InvokePesterParams['OutputFile'] -replace '.xml$','.xlsx'}
if (-not $UseExisting) {
$InvokePesterParams.Remove('Append')
$InvokePesterParams.Remove('UseExisting')
$InvokePesterParams.Remove('Show')
$InvokePesterParams.Remove('WorkSheetName')
@@ -73,7 +73,10 @@ $os = $resultXML.environment.platform -replace '\|.*$'," $($resultXML.e
Test-Suite [Name] = Context block name [result], [Time] to execute etc.
Results
Test-Case [name] = Describe.Context.It block names [description]= it block name, result], [Time] to execute etc
or if the tests are parameterized
Test suite [description] - name in the the it block with <vars> not filled in
Results
Test-case [description] - name as rendered for display with <vars> filled in
#>
$testResults = foreach ($test in $resultXML.'test-suite'.results.'test-suite') {
$testPs1File = $test.name
@@ -83,7 +86,11 @@ $testResults = foreach ($test in $resultXML.'test-suite'.results.'test-suite') {
$Describe = $suite.description
foreach ($subsuite in $suite.results.'test-suite') {
$Context = $subsuite.description
$subsuite.results.'test-case'| ForEach-Object {
if ($subsuite.results.'test-suite'.results.'test-case') {
$testCases = $subsuite.results.'test-suite'.results.'test-case'
}
else {$testCases = $subsuite.results.'test-case'}
$testCases | ForEach-Object {
New-Object -TypeName psobject -Property ([ordered]@{
Machine = $machine ; OS = $os
Date = $startDate ; Time = $startTime
@@ -110,9 +117,10 @@ $testResults = foreach ($test in $resultXML.'test-suite'.results.'test-suite') {
}
}
}
$excel = $testResults | Export-Excel -Path $xlFile -WorkSheetname $WorkSheetName -ClearSheet -PassThru -BoldTopRow -FreezeTopRow -AutoSize -AutoFilter -AutoNameRange
$ws = $excel.Workbook.Worksheets["PesterResults"]
if (-not $testResults) {Write-Warning 'No Results found' ; return}
$clearSheet = -not $Append
$excel = $testResults | Export-Excel -Path $xlFile -WorkSheetname $WorkSheetName -ClearSheet:$clearSheet -Append:$append -PassThru -BoldTopRow -FreezeTopRow -AutoSize -AutoFilter -AutoNameRange
$ws = $excel.Workbook.Worksheets[$WorkSheetName]
<# Worksheet should look like ...
|A |B |C D |E |F |G |H |I |J |K |L

View File

@@ -29,7 +29,7 @@ Describe 'ConvertFrom-ExcelSheet / Export-ExcelSheet' {
$secondText[1] | Should -Belike "*$date*"
$secondText[1] | Should -Match '"0\d","\w+","\d{1,2}"$'
$ThirdText[1] | Should -Match '^"\w+ \w+","#\d\d/\d\d/\d{4}#","\d","0\d"$'
$FourthText[1] | Should -Match '^"\w+","[012]\d'
$FourthText[1] | Should -Match '^"\w+","([012]\d/|[1-9]/)'
}
}
Context "Export aliased to ConvertFrom" {