Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlonGvili opened this issue Aug 14, 2021 · 3 comments · May be fixed by #2607
Open

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

AlonGvili opened this issue Aug 14, 2021 · 3 comments · May be fixed by #2607
Labels

Comments

@AlonGvili
Copy link

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     :
@fflaten
Copy link
Collaborator

fflaten commented Jul 17, 2022

If implemented, NUnit3-console stores it in the xml-report as both a property and reason-element:

<test-case ....>
  <properties>
    <property name="_SKIPREASON" value="Test needs modification" />
  </properties>
  <reason>
    <message><![CDATA[Test needs modification]]></message>
  </reason>
</test-case>

@corbob
Copy link

corbob commented Dec 6, 2024

If someone were to submit a PR to implement this, is it something that the project would be interested in reviewing and merging? This is a feature that I would very much like to see, and would be willing to attempt to implement.

@corbob corbob linked a pull request Jan 9, 2025 that will close this issue
10 tasks
@corbob
Copy link

corbob commented Jan 9, 2025

I've taken a stab at implementing something for this in #2607, as well as updating Set-ItResult so that it's reasons are also exported to the rest results. It is currently WIP as I have to cleanup the commit messages, and remove some extraneous files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants