From 2a0395965f6858bc41891bbfbbfcb71918649dce Mon Sep 17 00:00:00 2001 From: dfinke Date: Sat, 16 Jun 2018 10:03:42 -0400 Subject: [PATCH] Creates tests file and invokes the test runner --- Examples/TestRestAPI/TestAPIReadXls.ps1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Examples/TestRestAPI/TestAPIReadXls.ps1 b/Examples/TestRestAPI/TestAPIReadXls.ps1 index 38df9be..6b949b6 100644 --- a/Examples/TestRestAPI/TestAPIReadXls.ps1 +++ b/Examples/TestRestAPI/TestAPIReadXls.ps1 @@ -20,22 +20,26 @@ function Test-APIReadXls { $params.Uri += "?{0}" -f $record.QueryString } -@" + @" it "Should have the expected result '$($record.ExpectedResult)'" { `$target = '$($params | ConvertTo-Json -compress)' | ConvertFrom-Json - `$target.psobject.Properties.name | % {`$p=@{}} {`$p.`$_=`$(`$target.`$_)} + + `$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)} + Invoke-RestMethod @p | Should Be '$($record.ExpectedResult)' } "@ }) -@" + $testFileName = "{0}.tests.ps1" -f (get-date).ToString("yyyyMMddHHmmss.fff") + + @" Describe "Tests from $($XlFilename) in $($WorksheetName)" { $($blocks) } -"@ -} +"@ | Set-Content -Encoding Ascii $testFileName -Test-APIReadXls .\testlist.xlsx \ No newline at end of file + Invoke-Pester -Script (dir $testFileName) +} \ No newline at end of file