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

CodeCoverage.OutputEncoding ignored in xml encoding-attribute #2450

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

CodeCoverage.OutputEncoding ignored in xml encoding-attribute #2450

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?

CodeCoverage XML reports always report encoding="utf-8" regardless of CodeCoverage.OutputEncoding configuration option. The file itself is written using the selected encoding.

Related comment: #2298 (comment)

Expected Behavior

XML report should report the correct encoding in xml declaration.

Steps To Reproduce

# Executed in pester-repo
$c = New-PesterConfiguration
$c.Run.Path = './tst/functions/assertions'
$c.Run.ExcludePath = '*/demo/*', '*/examples/*', '*/testProjects/*', '*/Pester.Tests.ps1'
$c.Output.Verbosity = 'Detailed'
$c.CodeCoverage.Enabled = $true
$c.CodeCoverage.Path = './src/functions'
$c.CodeCoverage.UseBreakpoints = $false
$c.CodeCoverage.OutputFormat = 'JaCoCo'
$c.CodeCoverage.OutputEncoding = 'unicode' #utf-16
Invoke-Pester -Configuration $c

Generated coverage.xml is UTF-16 LE, but says <?xml version="1.0" encoding="UTF-8" standalone="no"?>

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?

  1. Improve type for configuration option or limit current string option to valid encodings. Related issue Invoke-Pester breaks on invalid CodeCoverage.OutputEncoding format #2451

  2. Remove/replace hard-coded value here:

    $jaCoCoReport = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'

  3. Consider replacing Out-File with XmlWriter and XmlWriterSettings.Encoding-option like TestResults? See related issue TestResults.OutputEncoding option ignored #2452

@fflaten fflaten added the Bug label May 13, 2024
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