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

Pester 5.5 reports incorrect Skipped results for Pending and Inconclusive #2413

Closed
3 tasks done
Scal-Human opened this issue Dec 18, 2023 · 3 comments
Closed
3 tasks done

Comments

@Scal-Human
Copy link

Checklist

What is the issue?

The results reported by Pester are incorrect when using Set-ItResult.
It reports Skipped while expecting Pending or Inconclusive.

Expected Behavior

When the Set-ItResult is used the result should be the given one (Pending or Inconclusive).

Steps To Reproduce

Having

Describe 'Pester <Version>' -ForEach @(
    @{ Version = '{0} on {1} with PowerShell {2}' -f (Get-Module Pester).Version, [Environment]::OSVersion, $PSVersionTable.PSVersion }
) {
    Context 'Correct results' {
        It 'Passes'             { 'Ok' | Should -Not -Be $Null }
        It 'Fails'              { Throw 'Failing' }
        It 'Is skipped 1' -Skip { 'Will be skipped' }
        It 'Is skipped 2'       { Set-ItResult -Skip }
    }
    Context 'Incorrect results' {
        It 'Is pending 1'       { Set-ItResult -Pending }
        It 'Is pending 2'       { Set-ItResult -Pending -Because 'With reason' }
        It 'Is inconclusive 1'  { Set-ItResult -Inconclusive }
        It 'Is inconclusive 2'  { Set-ItResult -Inconclusive -Because 'With reason' }
    }
}

and calling

(Invoke-Pester -Configuration (@{ Output = @{ Verbosity = 'Detailed' }; Run = @{ PassThru = `$True; Path = 'Pester-Tests.ps1' } })).Tests | Format-Table Result, ExpandedPath, ErrorRecord

Describe your environment

Output is

Pester v5.5.0

Starting discovery in 1 files.
Discovery found 8 tests in 224ms.
Running tests.

Running tests from 'C:\Project\Poc\Source\PowerShellTest\Deck\Pester-Tests.ps1'
Describing Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0
 Context Correct results
   [+] Passes 125ms (87ms|38ms)
   [-] Fails 9ms (7ms|1ms)
    RuntimeException: Failing
    at <ScriptBlock>, C:\Project\Poc\Source\PowerShellTest\Deck\Pester-Tests.ps1:6
   [!] Is skipped 1 3ms (0ms|3ms)
   [!] Is skipped 2 is skipped 12ms (11ms|1ms)
 Context Incorrect results
   [!] Is pending 1 is skipped, because PENDING 8ms (3ms|5ms)
   [!] Is pending 2 is skipped, because PENDING: With reason 8ms (3ms|5ms)
   [!] Is inconclusive 1 is skipped, because INCONCLUSIVE 3ms (2ms|1ms)
   [!] Is inconclusive 2 is skipped, because INCONCLUSIVE: With reason 3ms (2ms|1ms)
Tests completed in 947ms
Tests Passed: 1, Failed: 1, Skipped: 6 NotRun: 0

passthru content is

Result  ExpandedPath                                                                                                ErrorRecord
------  ------------                                                                                                -----------
Passed  Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Correct results.Passes              {}
Failed  Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Correct results.Fails               {Failing}
Skipped Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Correct results.Is skipped 1        {}
Skipped Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Correct results.Is skipped 2        {is skipped}
Skipped Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Incorrect results.Is pending 1      {is skipped, because PENDING}
Skipped Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Incorrect results.Is pending 2      {is skipped, because PENDING: With reason}
Skipped Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Incorrect results.Is inconclusive 1 {is skipped, because INCONCLUSIVE}
Skipped Pester 5.5.0 on Microsoft Windows NT 10.0.19045.0 with PowerShell 7.4.0.Incorrect results.Is inconclusive 2 {is skipped, because INCONCLUSIVE: With reason}

Possible Solution?

None

@Scal-Human Scal-Human changed the title Pester 5.5 resports incorrect Skipped results for Pending and Inconclusive Pester 5.5 reports incorrect Skipped results for Pending and Inconclusive Dec 18, 2023
@fflaten
Copy link
Collaborator

fflaten commented Dec 18, 2023

Hi. This was a known breaking changes in v5 to be considered in the future.

Inconclusive and Pending states are currently no longer available, -Pending and -Inconclusive are translated to -Skip both on test blocks and when using Set-ItResult

A PR is currently being reviewed to implement Inconclusive and deprecate Pending, see #2405. 🙂

@Scal-Human
Copy link
Author

Hi, yes, I saw it but I was fooled by the deprecation aspect.
I looked at the code and saw nothing concerning Inconclusive except the title.
It is important to preserve the Inconclusive while indeed the Pending is less useful.
Thanks,
Have a nice day

@fflaten
Copy link
Collaborator

fflaten commented Dec 18, 2023

It is important to preserve the Inconclusive while indeed the Pending is less useful.

👍 Closing as kinda duplicate of #2400 with the mentioned PR.
Thanks for using Pester. Have a great week.

@fflaten fflaten closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants