且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Pester PowerShell测试提示多次输入

更新时间:2023-09-07 22:10:10

标记参数Mandatory时,必须为其提供输入值-否则将提示您输入一个值.

When you mark a parameter Mandatory, you MUST supply an input value to it - otherwise it will prompt you for one.

来自 Get-Help about_Parameters :



 PARAMETER ATTRIBUTE TABLE
 [...] 
   Parameter Required?
     This setting indicates whether the parameter is mandatory, that
     is, whether all commands that use this cmdlet must include this
     parameter. When the value is "True" and the parameter is missing
     from the command, Windows PowerShell prompts you for a value for
     the parameter.

将测试更改为:

Describe -Tags "Example" "Palindrome1" {
    It "does something useful" {
        Palindrome1 -param "value goes here" | Should Be $true
    }
}