问题
By default, the output in the pipeline is hidden,But sometimes I really want to know the output at that time.
Of course, I knew I could add additional commands, such as write-host or out-default.
But does Pester itself have a mechanism to make the output display properly?
I checked the help document and didn't find the relevant content, so I came here for help.
回答1:
It is possible to write a custom Should
wrapper (proxy) using this technique. The wrapper can write the pipeline objects to the console.
Here is a complete example of such a Should
wrapper and how to override Pester's Should
.
To apply it to your case, edit the process{}
block of the wrapper like this:
process {
try {
# Here $_ is the current pipeline object
Write-Host "Current test case input:`n$( $_ | Out-String )"
# forward it to "process" block of original "Should"
$steppablePipeline.Process( $_ )
} catch {
throw
}
}
来源:https://stackoverflow.com/questions/65490526/how-to-make-the-output-in-the-pipeline-appear-on-the-console-when-running-pester