我写了一个纠缠测试来检查某些文件夹和文件是否存在。纠缠测试效果很好,但如果使用 -Verbose 选项调用测试,我想包括修复建议。但我似乎无法将 -Verbose 参数用于实际测试。
文件夹/文件结构:
Custom-PowerShellModule
| Custom-PowerShellModule.psd1
| Custom-PowerShellModule.psm1
\---Tests
Module.Tests.ps1
以下只是纠缠测试的顶部:
$Here = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
Describe "Module Minimum Requirements Tests. Use -Verbose for Suggested Fixes" -Tags Module {
Context "Test: Verify File Counts = 1" {
Write-Verbose "If you receive an error, verify there is only 'ONE' PSD1 File and only 'ONE' PSM1 File."
It "There is only one PSD1 file" { (Get-ChildItem "$Here\..\" *.psd1).count | Should be 1 }
It "There is only one PSM1 file" { (Get-ChildItem "$Here\..\" *.psm1).count | Should be 1 }
}
}