Skip to content

Testing without Throwing with Test

unknown edited this page Feb 11, 2013 · 1 revision

Testing without Throwing with -Test

If you like the Should sytax, but don't want it to throw, and would rather have it just return $true or $false, you can just use the -test option.

@(1,2,3) | Should Be @(1,2) -test
# outputs $false

In this case, the should expression is evaluated, but an exception is not thrown. Instead Should returns $false.