Creates tests file and invokes the test runner

This commit is contained in:
dfinke
2018-06-16 10:03:42 -04:00
parent 71330f31e5
commit 2a0395965f

View File

@@ -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
Invoke-Pester -Script (dir $testFileName)
}