Set-ItResult
Contributions are welcome in Pester v4-repo.
SYNOPSIS
Set-ItResult is used inside the It block to explicitly set the test result
SYNTAX
Inconclusive
Set-ItResult [-Inconclusive] [-Because <string>]
Pending
Set-ItResult [-Pending] [-Because <string>]
Skipped
Set-ItResult [-Skipped] [-Because <string>]
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.
EXAMPLES
EXAMPLE 1
Describe "Example" {
It "Inconclusive result test" {
Set-ItResult -Inconclusive -Because "we want it to be inconclusive"
}
}
the output should be
[?] Inconclusive result test, is inconclusive, because we want it to be inconclusive
Tests completed in 0ms
Tests Passed: 0, Failed: 0, Skipped: 0, Pending: 0, Inconclusive 1
EXAMPLE 2
Describe "Example" {
It "Skipped test" {
Set-ItResult -Skipped -Because "we want it to be skipped"
}
}
the output should be
[!] Skipped test, is skipped, because we want it to be skipped
Tests completed in 0ms
Tests Passed: 0, Failed: 0, Skipped: 0, Pending: 0, Inconclusive 1
PARAMETERS
-Because
Similarily 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: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Inconclusive
Sets the test result to inconclusive. Cannot be used at the same time as -Pending or -Skipped
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Inconclusive
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Pending
Sets the test result to pending. Cannot be used at the same time as -Inconclusive or -Skipped
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Pending
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Skipped
Sets the test result to skipped. Cannot be used at the same time as -Inconclusive or -Pending
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Skipped
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
OUTPUTS
NOTES
RELATED LINKS
VERSION
This page was generated using comment-based help in Pester 4.10.1.