'How can I catch DriveNotFoundException error when invoking pester?
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|