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

Duplicated because in output from Set-ItResult #2601

Closed
3 tasks done
fmad opened this issue Jan 9, 2025 · 1 comment
Closed
3 tasks done

Duplicated because in output from Set-ItResult #2601

fmad opened this issue Jan 9, 2025 · 1 comment

Comments

@fmad
Copy link

fmad commented Jan 9, 2025

Checklist

What is the issue?

When using Set-ItResult, a duplicate because and an extra space is output:

cat .\test-docs.ps1 && Invoke-Pester .\test-docs.ps1 -Output Detailed
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"
    }
}
Pester v5.6.1

Starting discovery in 1 files.
Discovery found 2 tests in 15ms.
Running tests.

Running tests from 'C:\git\Platform\test-docs.ps1'
Describing Example
  [?] Inconclusive test is inconclusive, because  because we want it to be inconclusive, 3ms (2ms|1ms)
  [!] Skipped test is skipped, because  because we want it to be skipped, 2ms (2ms|1ms)
Tests completed in 54ms
Tests Passed: 0, Failed: 0, Skipped: 1, Inconclusive: 1, NotRun: 0

Expected Behavior

For it to behave as per the documentation:

Get-Help Set-ItResult -Examples

NAME
    Set-ItResult
    
SYNOPSIS
    Set-ItResult is used inside the It block to explicitly set the test result
    
    
    -------------------------- EXAMPLE 1 --------------------------
    
    PS > ```powershell
    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
    ```

Steps To Reproduce

Just copy the example from Get-Help Set-ItResult -Examples into a new file and Invoke-Pester thatfile -Output Detailed

Describe your environment

Pester version : 5.6.1 C:\Users\XXXXX\Documents\PowerShell\Modules\Pester\5.6.1\Pester.psm1
PowerShell version : 7.4.6
OS version : Microsoft Windows NT 10.0.22631.0

Possible Solution?

Sorry, I have not delved into Pester's code yet.

@fflaten
Copy link
Collaborator

fflaten commented Jan 9, 2025

Good news. This is already fixed (#2589) and released in 5.7.1 yesterday. 🥳

@fflaten fflaten closed this as completed Jan 9, 2025
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