Assert-True

Asserts a condition is true.

Syntax

Assert-True [[-Condition] <Object>] [[-Message] <String>] [<CommonParameters>]

Description

Uses PowerShell's rules for determinig truthiness. All values are true except:

All other values are true.

Parameters

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 Condition isn't $true.

false false

EXAMPLE 1

Assert-True $false

Demonstrates how to fail a test.

EXAMPLE 2

Assert-True (Invoke-SomethingThatShouldReturnSomething)

Demonstrates how to check that a function returns a true object/value.

EXAMPLE 3

Assert-False $true 'The fladoozle didn't dooflaple.'

Demonstrates how to use the Message parameter to describe why the assertion might have failed.