Testing for mandatory parameters with Pester
问题 I'm trying to figure out how to have Pester test for parameters that are missing: Find-Waldo.Tests.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' Describe 'Mandatory paramters' { it 'ComputerName' { { $Params = @{ #ComputerName = 'MyPc' ScriptName = 'Test' } . "$here\$sut" @Params } | Should throw } } Find-Waldo.ps1 Param ( [Parameter(Mandatory)] [String]$ComputerName, [String]$ScriptName ) Function