I can’t test for a null or empty string with Pester

Problem:

I need to test for a Null or empty string but my test fails with the following error.

Solution:

Make sure you use “Should BeNullOrEmpty” and not “Should Be NullOrEmpty”.

Explanation:

When I originally wrote the test I wrote the assert like this:

$result | Should Be NullOrEmpty

Which resulted in the error I showed above.  Removing the space between Be and NullOrEmpty now passes as expected.

$result | Should BeNullOrEmpty

Add comment

Loading