调用 pester 时如何捕获 DriveNotFoundException 错误?
我有一个 powershell 脚本,它并行调用 Pester 的实例,其中:
Invoke-Pester @{Path= "somepath/file.tests.ps1";
Parameters = @{...
...}} -Tag 'value' -OutputFile $xmlpath -OutputFormat NUnitXML -EnableExit
经常有一次运行,其中至少一个调用 pester 的实例在外部失败,抛出 DriveNotFoundException:
Executing script somepath/file.tests.ps1
Describing Testcase
[-] Error occurred in Describe block
0ms
DriveNotFoundException: Cannot find drive. A drive with the name 'TestRegistry' does not exist.
at Get-TestRegistryPath, C:\Users\VssAdministrator\Documents\PowerShell\Modules\Pester\4.6.0\Functions\TestRegistry.ps1: line 60
我一直无法捕获此问题错误,可以是:
try {Invoke-Pester @{Path= "somepath/file.tests.ps1";
Parameters = @{...
...}} -Tag 'value' -OutputFile $xmlpath -OutputFormat NUnitXML -EnableExit} catch {...}
或
try {
Describe "Testcase" -Tag 'value' {...}
} catch { ... }
如何捕获此错误?
I have a powershell script, which in parallel, invokes instances of Pester, with:
Invoke-Pester @{Path= "somepath/file.tests.ps1";
Parameters = @{...
...}} -Tag 'value' -OutputFile $xmlpath -OutputFormat NUnitXML -EnableExit
There is often a run, whereby at least one of the instances to invoke pester, fails at the outside, throwing a DriveNotFoundException:
Executing script somepath/file.tests.ps1
Describing Testcase
[-] Error occurred in Describe block
0ms
DriveNotFoundException: Cannot find drive. A drive with the name 'TestRegistry' does not exist.
at Get-TestRegistryPath, C:\Users\VssAdministrator\Documents\PowerShell\Modules\Pester\4.6.0\Functions\TestRegistry.ps1: line 60
I have been unable to catch this error, with either:
try {Invoke-Pester @{Path= "somepath/file.tests.ps1";
Parameters = @{...
...}} -Tag 'value' -OutputFile $xmlpath -OutputFormat NUnitXML -EnableExit} catch {...}
or
try {
Describe "Testcase" -Tag 'value' {...}
} catch { ... }
How can I catch this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论