Skip to main content
Version: v4

Should

SYNOPSIS#

Should is a keyword what is used to define an assertion inside It block.

SYNTAX#

Legacy (Default)#

Should [[-__LegacyArg1] <Object>] [[-__LegacyArg2] <Object>] [[-__LegacyArg3] <Object>] [-ActualValue <Object>] [<CommonParameters>]

Be#

Should [-ActualValue <Object>] [-Be] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [<CommonParameters>]

BeExactly#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeExactly] [<CommonParameters>]

BeGreaterThan#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeGreaterThan] [<CommonParameters>]

BeLessOrEqual#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeLessOrEqual] [<CommonParameters>]

BeIn#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeIn] [<CommonParameters>]

BeLessThan#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeLessThan] [<CommonParameters>]

BeGreaterOrEqual#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeGreaterOrEqual] [<CommonParameters>]

BeLike#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeLike] [<CommonParameters>]

BeLikeExactly#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-BeLikeExactly] [<CommonParameters>]

BeNullOrEmpty#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-BeNullOrEmpty] [<CommonParameters>]

BeOfType#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-BeOfType] [-ExpectedType <Object>] [<CommonParameters>]

BeTrue#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-BeTrue] [<CommonParameters>]

BeFalse#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-BeFalse] [<CommonParameters>]

Contain#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-Contain] [<CommonParameters>]

Exist#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-Exist] [<CommonParameters>]

FileContentMatch#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-FileContentMatch] [-ExpectedContent <Object>] [<CommonParameters>]

FileContentMatchExactly#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-ExpectedContent <Object>] [-FileContentMatchExactly] [<CommonParameters>]

FileContentMatchMultiline#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-ExpectedContent <Object>] [-FileContentMatchMultiline] [<CommonParameters>]

HaveCount#

Should [-ActualValue <Object>] [-Not] [-ExpectedValue <Object>] [-Because <Object>] [-HaveCount] [<CommonParameters>]

HaveParameter#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-HaveParameter] [-ParameterName <Object>] [-Type <Object>] [-DefaultValue <Object>] [-Mandatory] [-HasArgumentCompleter] [<CommonParameters>]

Match#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-Match] [-RegularExpression <Object>] [<CommonParameters>]

MatchExactly#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-RegularExpression <Object>] [-MatchExactly] [<CommonParameters>]

Throw#

Should [-ActualValue <Object>] [-Not] [-Because <Object>] [-Throw] [-ExpectedMessage <Object>] [-ErrorId <Object>] [-ExceptionType <Object>] [-PassThru] [<CommonParameters>]

DESCRIPTION#

Should is a keyword what is used to define an assertion inside the It block. Should provides assertion methods for verify assertion e.g. comparing objects. If assertion is not met the test fails and an exception is throwed up.

Should can be used more than once in the It block if more than one assertion need to be verified. Each Should keywords need to be located in a new line. Test will be passed only when all assertion will be met (logical conjuction).

EXAMPLES#

Example 1#

PS C:\> {{ Add example code here }}

{{ Add example description here }}

PARAMETERS#

-__LegacyArg1#

{{ Fill __LegacyArg1 Description }}

Type: ObjectParameter Sets: LegacyAliases:
Required: FalsePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-__LegacyArg2#

{{ Fill __LegacyArg2 Description }}

Type: ObjectParameter Sets: LegacyAliases:
Required: FalsePosition: 2Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-__LegacyArg3#

{{ Fill __LegacyArg3 Description }}

Type: ObjectParameter Sets: LegacyAliases:
Required: FalsePosition: 3Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ActualValue#

{{ Fill ActualValue Description }}

Type: ObjectParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: True (ByValue)Accept wildcard characters: False

-Be#

{{ Fill Be Description }}

Type: SwitchParameterParameter Sets: BeAliases: EQ
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Because#

{{ Fill Because Description }}

Type: ObjectParameter Sets: Be, BeExactly, BeGreaterThan, BeLessOrEqual, BeIn, BeLessThan, BeGreaterOrEqual, BeLike, BeLikeExactly, BeNullOrEmpty, BeOfType, BeTrue, BeFalse, Contain, Exist, FileContentMatch, FileContentMatchExactly, FileContentMatchMultiline, HaveCount, HaveParameter, Match, MatchExactly, ThrowAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeExactly#

{{ Fill BeExactly Description }}

Type: SwitchParameterParameter Sets: BeExactlyAliases: CEQ
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeFalse#

{{ Fill BeFalse Description }}

Type: SwitchParameterParameter Sets: BeFalseAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeGreaterOrEqual#

{{ Fill BeGreaterOrEqual Description }}

Type: SwitchParameterParameter Sets: BeGreaterOrEqualAliases: GE
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeGreaterThan#

{{ Fill BeGreaterThan Description }}

Type: SwitchParameterParameter Sets: BeGreaterThanAliases: GT
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeIn#

{{ Fill BeIn Description }}

Type: SwitchParameterParameter Sets: BeInAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeLessOrEqual#

{{ Fill BeLessOrEqual Description }}

Type: SwitchParameterParameter Sets: BeLessOrEqualAliases: LE
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeLessThan#

{{ Fill BeLessThan Description }}

Type: SwitchParameterParameter Sets: BeLessThanAliases: LT
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeLike#

{{ Fill BeLike Description }}

Type: SwitchParameterParameter Sets: BeLikeAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeLikeExactly#

{{ Fill BeLikeExactly Description }}

Type: SwitchParameterParameter Sets: BeLikeExactlyAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeNullOrEmpty#

{{ Fill BeNullOrEmpty Description }}

Type: SwitchParameterParameter Sets: BeNullOrEmptyAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeOfType#

{{ Fill BeOfType Description }}

Type: SwitchParameterParameter Sets: BeOfTypeAliases: HaveType
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-BeTrue#

{{ Fill BeTrue Description }}

Type: SwitchParameterParameter Sets: BeTrueAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Contain#

{{ Fill Contain Description }}

Type: SwitchParameterParameter Sets: ContainAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-DefaultValue#

{{ Fill DefaultValue Description }}

Type: ObjectParameter Sets: HaveParameterAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ErrorId#

{{ Fill ErrorId Description }}

Type: ObjectParameter Sets: ThrowAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ExceptionType#

{{ Fill ExceptionType Description }}

Type: ObjectParameter Sets: ThrowAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Exist#

{{ Fill Exist Description }}

Type: SwitchParameterParameter Sets: ExistAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ExpectedContent#

{{ Fill ExpectedContent Description }}

Type: ObjectParameter Sets: FileContentMatch, FileContentMatchExactly, FileContentMatchMultilineAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ExpectedMessage#

{{ Fill ExpectedMessage Description }}

Type: ObjectParameter Sets: ThrowAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ExpectedType#

{{ Fill ExpectedType Description }}

Type: ObjectParameter Sets: BeOfTypeAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ExpectedValue#

{{ Fill ExpectedValue Description }}

Type: ObjectParameter Sets: Be, BeExactly, BeGreaterThan, BeLessOrEqual, BeIn, BeLessThan, BeGreaterOrEqual, BeLike, BeLikeExactly, Contain, HaveCountAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-FileContentMatch#

{{ Fill FileContentMatch Description }}

Type: SwitchParameterParameter Sets: FileContentMatchAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-FileContentMatchExactly#

{{ Fill FileContentMatchExactly Description }}

Type: SwitchParameterParameter Sets: FileContentMatchExactlyAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-FileContentMatchMultiline#

{{ Fill FileContentMatchMultiline Description }}

Type: SwitchParameterParameter Sets: FileContentMatchMultilineAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-HasArgumentCompleter#

{{ Fill HasArgumentCompleter Description }}

Type: SwitchParameterParameter Sets: HaveParameterAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-HaveCount#

{{ Fill HaveCount Description }}

Type: SwitchParameterParameter Sets: HaveCountAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-HaveParameter#

{{ Fill HaveParameter Description }}

Type: SwitchParameterParameter Sets: HaveParameterAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Mandatory#

{{ Fill Mandatory Description }}

Type: SwitchParameterParameter Sets: HaveParameterAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Match#

{{ Fill Match Description }}

Type: SwitchParameterParameter Sets: MatchAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-MatchExactly#

{{ Fill MatchExactly Description }}

Type: SwitchParameterParameter Sets: MatchExactlyAliases: CMATCH
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Not#

{{ Fill Not Description }}

Type: SwitchParameterParameter Sets: Be, BeExactly, BeGreaterThan, BeLessOrEqual, BeIn, BeLessThan, BeGreaterOrEqual, BeLike, BeLikeExactly, BeNullOrEmpty, BeOfType, BeTrue, BeFalse, Contain, Exist, FileContentMatch, FileContentMatchExactly, FileContentMatchMultiline, HaveCount, HaveParameter, Match, MatchExactly, ThrowAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ParameterName#

{{ Fill ParameterName Description }}

Type: ObjectParameter Sets: HaveParameterAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-PassThru#

{{ Fill PassThru Description }}

Type: SwitchParameterParameter Sets: ThrowAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-RegularExpression#

{{ Fill RegularExpression Description }}

Type: ObjectParameter Sets: Match, MatchExactlyAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Throw#

{{ Fill Throw Description }}

Type: SwitchParameterParameter Sets: ThrowAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-Type#

{{ Fill Type Description }}

Type: ObjectParameter Sets: HaveParameterAliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

CommonParameters#

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS#

OUTPUTS#

NOTES#

RELATED LINKS#

EDIT THIS PAGE#

This page was auto-generated using Pester's comment based help. To edit the content of this page, change the corresponding help in the pester/Pester v4 repository. See our contribution guide for more information.