Я пытаюсь выполнить модульное тестирование моего файла сценария Powershell с приведенным ниже фрагментом кода, используя Pester
#code to create a 7z file
$7zipPath = "C:\Program Files\7-Zip\7z.exe"
Set-Alias 7zip $7zipPath
if (!(Test-Path -Path $7zipPath -PathType Leaf)) {
throw "7 zip file '$7zipPath' not found"
}
7zip a -mx=9 $jenkinsWorkspacepath\IntegrationZip.7z $jenkinsWorkspacepath\IntegratedScripts
И издеваясь над командой Test-Path, как показано ниже
Mock -CommandName Test-Path –MockWith {
Return $false
}
Но отчет о покрытии показывает нижнюю строку как непокрытую .. Что я делаю здесь не так (в насмешливой части)?
**throw "7 zip file '$7zipPath' not found"**