I have this test:
It 'Should not find environment' {
{Add-Patchgroup -ComputerName $serversHash.serverWithNotExistingEnvironment -WarningVariable warning -WarningAction SilentlyContinue}
$warning | Should -BeLike ('*55555*')
}
$warning contains this string (exactly as you see here with the newline and whitespace on the second row):
Could not add <nameOfTheServer> to patchgroup
Exception message: Environment F was not found
But my test is passing which it should not:
Context Find the environment
[+] Should not find environment 79ms
[+] Should find environment 147ms
It seems like the test is not working at all even with -Be parameter. The test is still passing.
$warning | Should -Be 'randomrandom'