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: Object
Parameter Sets: Legacy
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-__LegacyArg2

{{ Fill __LegacyArg2 Description }}

Type: Object
Parameter Sets: Legacy
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-__LegacyArg3

{{ Fill __LegacyArg3 Description }}

Type: Object
Parameter Sets: Legacy
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ActualValue

{{ Fill ActualValue Description }}

Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Be

{{ Fill Be Description }}

Type: SwitchParameter
Parameter Sets: Be
Aliases: EQ
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Because

{{ Fill Because Description }}

Type: Object
Parameter Sets: Be, BeExactly, BeGreaterThan, BeLessOrEqual, BeIn, BeLessThan, BeGreaterOrEqual, BeLike, BeLikeExactly, BeNullOrEmpty, BeOfType, BeTrue, BeFalse, Contain, Exist, FileContentMatch, FileContentMatchExactly, FileContentMatchMultiline, HaveCount, HaveParameter, Match, MatchExactly, Throw
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeExactly

{{ Fill BeExactly Description }}

Type: SwitchParameter
Parameter Sets: BeExactly
Aliases: CEQ
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeFalse

{{ Fill BeFalse Description }}

Type: SwitchParameter
Parameter Sets: BeFalse
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeGreaterOrEqual

{{ Fill BeGreaterOrEqual Description }}

Type: SwitchParameter
Parameter Sets: BeGreaterOrEqual
Aliases: GE
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeGreaterThan

{{ Fill BeGreaterThan Description }}

Type: SwitchParameter
Parameter Sets: BeGreaterThan
Aliases: GT
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeIn

{{ Fill BeIn Description }}

Type: SwitchParameter
Parameter Sets: BeIn
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeLessOrEqual

{{ Fill BeLessOrEqual Description }}

Type: SwitchParameter
Parameter Sets: BeLessOrEqual
Aliases: LE
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeLessThan

{{ Fill BeLessThan Description }}

Type: SwitchParameter
Parameter Sets: BeLessThan
Aliases: LT
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeLike

{{ Fill BeLike Description }}

Type: SwitchParameter
Parameter Sets: BeLike
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeLikeExactly

{{ Fill BeLikeExactly Description }}

Type: SwitchParameter
Parameter Sets: BeLikeExactly
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeNullOrEmpty

{{ Fill BeNullOrEmpty Description }}

Type: SwitchParameter
Parameter Sets: BeNullOrEmpty
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeOfType

{{ Fill BeOfType Description }}

Type: SwitchParameter
Parameter Sets: BeOfType
Aliases: HaveType
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BeTrue

{{ Fill BeTrue Description }}

Type: SwitchParameter
Parameter Sets: BeTrue
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Contain

{{ Fill Contain Description }}

Type: SwitchParameter
Parameter Sets: Contain
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-DefaultValue

{{ Fill DefaultValue Description }}

Type: Object
Parameter Sets: HaveParameter
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ErrorId

{{ Fill ErrorId Description }}

Type: Object
Parameter Sets: Throw
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ExceptionType

{{ Fill ExceptionType Description }}

Type: Object
Parameter Sets: Throw
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Exist

{{ Fill Exist Description }}

Type: SwitchParameter
Parameter Sets: Exist
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ExpectedContent

{{ Fill ExpectedContent Description }}

Type: Object
Parameter Sets: FileContentMatch, FileContentMatchExactly, FileContentMatchMultiline
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ExpectedMessage

{{ Fill ExpectedMessage Description }}

Type: Object
Parameter Sets: Throw
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ExpectedType

{{ Fill ExpectedType Description }}

Type: Object
Parameter Sets: BeOfType
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ExpectedValue

{{ Fill ExpectedValue Description }}

Type: Object
Parameter Sets: Be, BeExactly, BeGreaterThan, BeLessOrEqual, BeIn, BeLessThan, BeGreaterOrEqual, BeLike, BeLikeExactly, Contain, HaveCount
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FileContentMatch

{{ Fill FileContentMatch Description }}

Type: SwitchParameter
Parameter Sets: FileContentMatch
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FileContentMatchExactly

{{ Fill FileContentMatchExactly Description }}

Type: SwitchParameter
Parameter Sets: FileContentMatchExactly
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FileContentMatchMultiline

{{ Fill FileContentMatchMultiline Description }}

Type: SwitchParameter
Parameter Sets: FileContentMatchMultiline
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HasArgumentCompleter

{{ Fill HasArgumentCompleter Description }}

Type: SwitchParameter
Parameter Sets: HaveParameter
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HaveCount

{{ Fill HaveCount Description }}

Type: SwitchParameter
Parameter Sets: HaveCount
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HaveParameter

{{ Fill HaveParameter Description }}

Type: SwitchParameter
Parameter Sets: HaveParameter
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Mandatory

{{ Fill Mandatory Description }}

Type: SwitchParameter
Parameter Sets: HaveParameter
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Match

{{ Fill Match Description }}

Type: SwitchParameter
Parameter Sets: Match
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MatchExactly

{{ Fill MatchExactly Description }}

Type: SwitchParameter
Parameter Sets: MatchExactly
Aliases: CMATCH
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Not

{{ Fill Not Description }}

Type: SwitchParameter
Parameter Sets: Be, BeExactly, BeGreaterThan, BeLessOrEqual, BeIn, BeLessThan, BeGreaterOrEqual, BeLike, BeLikeExactly, BeNullOrEmpty, BeOfType, BeTrue, BeFalse, Contain, Exist, FileContentMatch, FileContentMatchExactly, FileContentMatchMultiline, HaveCount, HaveParameter, Match, MatchExactly, Throw
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ParameterName

{{ Fill ParameterName Description }}

Type: Object
Parameter Sets: HaveParameter
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

{{ Fill PassThru Description }}

Type: SwitchParameter
Parameter Sets: Throw
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RegularExpression

{{ Fill RegularExpression Description }}

Type: Object
Parameter Sets: Match, MatchExactly
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Throw

{{ Fill Throw Description }}

Type: SwitchParameter
Parameter Sets: Throw
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Type

{{ Fill Type Description }}

Type: Object
Parameter Sets: HaveParameter
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept 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 repository. See our contribution guide for more information.