Skip to main content
Version: v5

Set-ItResult

This page was generated

Contributions are welcome in Pester-repo.

SYNOPSIS​

Set-ItResult is used inside the It block to explicitly set the test result

SYNTAX​

Inconclusive​

Set-ItResult [-Inconclusive] [-Because <String>] [<CommonParameters>]

Pending​

Set-ItResult [-Pending] [-Because <String>] [<CommonParameters>]

Skipped​

Set-ItResult [-Skipped] [-Because <String>] [<CommonParameters>]

DESCRIPTION​

Sometimes a test shouldn't be executed, sometimes the condition cannot be evaluated. By default such tests would typically fail and produce a big red message. Using Set-ItResult it is possible to set the result from the inside of the It script block to either inconclusive, pending or skipped.

As of Pester 5, there is no "Inconclusive" or "Pending" test state, so all tests will now go to state skipped, however the test result notes will include information about being inconclusive or testing to keep this command backwards compatible

EXAMPLES​

EXAMPLE 1​

Describe "Example" {
It "Inconclusive test" {
Set-ItResult -Inconclusive -Because "we want it to be inconclusive"
}
It "Skipped test" {
Set-ItResult -Skipped -Because "we want it to be skipped"
}
}

the output should be

Describing Example
[?] Inconclusive test is inconclusive, because we want it to be inconclusive 35ms (32ms|3ms)
[!] Skipped test is skipped, because we want it to be skipped 3ms (2ms|1ms)
Tests completed in 78ms
Tests Passed: 0, Failed: 0, Skipped: 1, Inconclusive: 1, NotRun: 0

PARAMETERS​

-Inconclusive​

Sets the test result to inconclusive. Cannot be used at the same time as -Pending or -Skipped

Type: SwitchParameter
Parameter Sets: Inconclusive
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Pending​

DEPRECATED Sets the test result to pending. Cannot be used at the same time as -Inconclusive or -Skipped

Type: SwitchParameter
Parameter Sets: Pending
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Skipped​

Sets the test result to skipped. Cannot be used at the same time as -Inconclusive or -Pending

Type: SwitchParameter
Parameter Sets: Skipped
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Because​

Similarly to failing tests, skipped and inconclusive tests should have reason. It allows to provide information to the user why the test is neither successful nor failed.

Type: String
Parameter Sets: (All)
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​

https://pester.dev/docs/commands/Set-ItResult

VERSION​

This page was generated using comment-based help in Pester 5.6.1.