如何在 VSCode 中使用 -OutPutDetailed 快速运行 Pester?

And*_*ndy 5 powershell unit-testing pester visual-studio-code

在VSCode中按快捷键“Ctrl+F5”即可运行后缀为“.tests.ps1”的Pester测试文件。

\n

在'about_Parsing.Tests.ps1'中按“Ctrl+F5”后,直接出现控制台:d:\\GitRepository\\PowerShell\\example\\pester\\\xe2\x80\xaaabout_Parsing\\\xe2\ x80\xaaabout_Parsing.Tests.ps1

\n

然后直接运行测试。

\n

如何以如此方便的方式运行测试并使用各种invoke-pester参数,例如-output detailed

\n

Mar*_*agg 7

如果你进入 VSCode 的设置并搜索 Pester,你应该会找到一个名为:

PowerShell > Pester:输出详细程度

您可以将其设置为“详细”。

该设置还表明,如果您使用 Pester v5 或更高版本,您还可以通过 $PesterPreference默认使用的变量进行设置。您可以在脚本或 PowerShell 配置文件中设置此变量。

$PesterPreference = [PesterConfiguration]::Default
$PesterPreference.Output.Verbosity = 'Detailed'
Run Code Online (Sandbox Code Playgroud)