Asserts a condition is true.
Assert-True [[-Condition] <Object>] [[-Message] <String>] [<CommonParameters>]
Uses PowerShell's rules for determinig truthiness. All values are true except:
0
$false
[String]::Empty
)$null
@()
(i.e. empty arrays)All other values are true.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Condition | Object | The object/value to test for truthiness. |
false | false | |
Message | String | A message to show if |
false | false |
Assert-True $false
Demonstrates how to fail a test.
Assert-True (Invoke-SomethingThatShouldReturnSomething)
Demonstrates how to check that a function returns a true object/value.
Assert-False $true 'The fladoozle didn't dooflaple.'
Demonstrates how to use the Message
parameter to describe why the assertion might have failed.