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

TestResults.OutputEncoding option ignored #2452

Open
3 tasks done
fflaten opened this issue May 13, 2024 · 0 comments
Open
3 tasks done

TestResults.OutputEncoding option ignored #2452

fflaten opened this issue May 13, 2024 · 0 comments
Labels

Comments

@fflaten
Copy link
Collaborator

fflaten commented May 13, 2024

Checklist

What is the issue?

TestResults.OutputEncoding configuration option is ignored. XML delcaration is hardcoded to utf-8 and file is written in default encoding.

Expected Behavior

Configuration option should be properly typed to valid encodings and be effective.

Steps To Reproduce

$c = New-PesterConfiguration
$c.Run.ScriptBlock = {
    Describe 'd' {
        It 'i' { }
    }
}
$c.TestResult.Enabled = $true
$c.TestResult.OutputFormat = 'NUnit3'
$c.TestResult.OutputEncoding = 'utf-16'
$c.TestResult.TestSuiteName = 'TestResult.OutputEncoding Demo'
$c.TestResult.OutputPath = "./demoOutputEncoding.xml"
$c.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $c

demoOutputEncoding.xml is written in UTF-8 and incldues encoding="utf-8".

Describe your environment

Pester version : 5.6.0-beta1 /workspaces/Pester/bin/Pester.psm1
PowerShell version : 7.4.1
OS version : Unix 5.15.133.1

Possible Solution?

Improve type or early validation for configuration option to only allow valid encodings. Then pass it to Encoding-option here:

$settings = [Xml.XmlWriterSettings] @{
Indent = $true
NewLineOnAttributes = $false
}

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

No branches or pull requests

1 participant