From 171783cac757b941ebebb25e74a298f8b9fbacf2 Mon Sep 17 00:00:00 2001 From: dfinke Date: Sun, 24 Jun 2018 07:26:27 -0400 Subject: [PATCH] updated --- Examples/TestRestAPI/RunAndShowUnitTests.ps1 | 36 ++++++++++++++++++++ Examples/TestRestAPI/TestAPIReadXls.ps1 | 6 ++-- Examples/TestRestAPI/TryIt.ps1 | 6 +++- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 Examples/TestRestAPI/RunAndShowUnitTests.ps1 diff --git a/Examples/TestRestAPI/RunAndShowUnitTests.ps1 b/Examples/TestRestAPI/RunAndShowUnitTests.ps1 new file mode 100644 index 0000000..2bfd272 --- /dev/null +++ b/Examples/TestRestAPI/RunAndShowUnitTests.ps1 @@ -0,0 +1,36 @@ + +$xlfilename=".\test.xlsx" +rm $xlfilename -ErrorAction Ignore + +$ConditionalText = @() +$ConditionalText += New-ConditionalText -Range "C:C" -Text failed -BackgroundColor red -ConditionalTextColor black +$ConditionalText += New-ConditionalText -Range "C:C" -Text passed -BackgroundColor green -ConditionalTextColor black + +$r = .\TryIt.ps1 + +$xlPkg = $(foreach($result in $r.TestResult) { + + [PSCustomObject]@{ + Name = $result.Name + #Time = $result.Time + Result = $result.Result + Messge = $result.FailureMessage + StackTrace = $result.StackTrace + } + +}) | Export-Excel -Path $xlfilename -AutoSize -ConditionalText $ConditionalText -PassThru + +$sheet1 = $xlPkg.Workbook.Worksheets["sheet1"] + +$sheet1.View.ShowGridLines = $false +$sheet1.View.ShowHeaders = $false + +Set-Format -Address $sheet1.Cells["A:A"] -AutoSize +Set-Format -Address $sheet1.Cells["B:D"] -WrapText + +$sheet1.InsertColumn(1, 1) +Set-Format -Address $sheet1.Cells["A:A"] -Width 5 + +Set-Format -Address $sheet1.Cells["B1:E1"] -HorizontalAlignment Center -BorderBottom Thick -BorderColor Cyan + +Close-ExcelPackage $xlPkg -Show \ No newline at end of file diff --git a/Examples/TestRestAPI/TestAPIReadXls.ps1 b/Examples/TestRestAPI/TestAPIReadXls.ps1 index 6b949b6..4cae98a 100644 --- a/Examples/TestRestAPI/TestAPIReadXls.ps1 +++ b/Examples/TestRestAPI/TestAPIReadXls.ps1 @@ -41,5 +41,7 @@ $($blocks) } "@ | Set-Content -Encoding Ascii $testFileName - Invoke-Pester -Script (dir $testFileName) -} \ No newline at end of file + #Invoke-Pester -Script (Get-ChildItem $testFileName) + Get-ChildItem $testFileName +} + diff --git a/Examples/TestRestAPI/TryIt.ps1 b/Examples/TestRestAPI/TryIt.ps1 index 11b5336..2ab43f1 100644 --- a/Examples/TestRestAPI/TryIt.ps1 +++ b/Examples/TestRestAPI/TryIt.ps1 @@ -1 +1,5 @@ -Test-APIReadXls $PSScriptRoot\testlist.xlsx \ No newline at end of file +. $PSScriptRoot\TestAPIReadXls.ps1 + +Test-APIReadXls $PSScriptRoot\testlist.xlsx | % { + Invoke-Pester -Script $_.fullname -PassThru -Show None +} \ No newline at end of file