Open
Description
Checklist
- Issue has a meaningful title
- I have searched the existing issues. See all issues
- I have tested using the latest version of Pester. See Installation and update guide.
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:
Pester/src/functions/TestResults.ps1
Lines 169 to 172 in 93c6610