Skip to content

Feature: Add a -Reason parameter when using the -Skip switch  #2049

Open
@AlonGvili

Description

@AlonGvili

Summary of the feature request

Hey, I wonder if you can add What is the reason a test was skipped

the current return object you will get if you using -PassThru doesn't contain any info on this
maybe you can add parameter name -Reason 'the reason it skipped'

PS D:\Github\pwshchakraui> $results.Skipped[0]             


Name              : Has help comment block
Path              : {New-Tab, Comment Base Help, Has help comment block}
Data              :
ExpandedName      : Has help comment block
ExpandedPath      : New-Tab.Comment Base Help.Has help comment block
Result            : Skipped
ErrorRecord       : {}
StandardOutput    :
Duration          : 00:00:00.0054751
ItemType          : Test
Id                :
ScriptBlock       :
                                    $FilePath | Should -FileContentMatch "<#"
                                    $FilePath | Should -FileContentMatch "#>"

Tag               :
Focus             : False
Skip              : True
Block             : [!] Comment Base Help
First             : True
Last              : False
Include           : False
Exclude           : False
Explicit          : False
ShouldRun         : True
StartLine         : 9
Executed          : True
ExecutedAt        : 8/14/2021 11:43:21 AM
Passed            : True
Skipped           : True
UserDuration      : 00:00:00
FrameworkDuration : 00:00:00.0054751
PluginData        :
FrameworkData     :

How should it work? (optional)

Describe "describe1" {
    Context "with one skipped test" {
        It "test 1" -Skip -Reason 'i want it to skip' {
            1 | Should -Be 2
        }

        It "test 2" {
            1 | Should -Be 1
        }
    }

    Describe "that is skipped" -Skip -Reason 'i want it to skip all the tests' {
        It "test 3" {
            1 | Should -Be 2
        }
    }

    Context "that is skipped and has skipped test" -Skip -Reason 'i want all the It tests to skip' {
        It "test 3" -Skip {
            1 | Should -Be 2
        }

        It "test 3" {
            1 | Should -Be 2
        }
    }
}

So the return object will look something like this.

Name              : Has help comment block
Path              : {New-Tab, Comment Base Help, Has help comment block}
Data              :
ExpandedName      : Has help comment block
ExpandedPath      : New-Tab.Comment Base Help.Has help comment block
Result            : Skipped
ErrorRecord       : {}
StandardOutput    :
Duration          : 00:00:00.0054751
ItemType          : Test
Id                :
ScriptBlock       :
                                    $FilePath | Should -FileContentMatch "<#"
                                    $FilePath | Should -FileContentMatch "#>"

Tag               :
Focus             : False
Skip              : True
Block             : [!] Comment Base Help
First             : True
Last              : False
Include           : False
Exclude           : False
Explicit          : False
ShouldRun         : True
StartLine         : 9
Executed          : True
ExecutedAt        : 8/14/2021 11:43:21 AM
Passed            : True
Skipped           : True
SkippedReason  : I want it to skip
UserDuration      : 00:00:00
FrameworkDuration : 00:00:00.0054751
PluginData        :
FrameworkData     :

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions