Skip to content

Commit

Permalink
More escaping in nunit3 xml
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed Feb 20, 2025
1 parent f336967 commit 13af0b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/functions/TestResults.NUnit3.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ function Write-NUnit3TestCaseAttributes {
$XmlWriter.WriteAttributeString('id', (Get-NUnit3NodeId))
# Workaround - name-attribute should be $name, but CI-reports don't show the tree-view nor use fullname
# See https://github.com/pester/Pester/issues/1530#issuecomment-1186187298
$XmlWriter.WriteAttributeString('name', $fullname)
$XmlWriter.WriteAttributeString('fullname', $fullname)
$escapedFullName = (Format-CDataString $fullname)
$XmlWriter.WriteAttributeString('name', $escapedFullName)
$XmlWriter.WriteAttributeString('fullname', $escapedFullName)
$XmlWriter.WriteAttributeString('methodname', $TestResult.Name)
$XmlWriter.WriteAttributeString('classname', $TestResult.Block.Path -join '.')
$XmlWriter.WriteAttributeString('runstate', $runstate)
Expand Down Expand Up @@ -646,7 +647,7 @@ function Write-NUnit3DataProperty ([System.Collections.IDictionary] $Data, [Syst

$XmlWriter.WriteStartElement('property')
$XmlWriter.WriteAttributeString('name', $name)
$XmlWriter.WriteAttributeString('value', $formattedValue)
$XmlWriter.WriteAttributeString('value', (Format-CDataString $formattedValue))
$XmlWriter.WriteEndElement() # Close property
}
}
Expand Down
1 change: 1 addition & 0 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ if ($CI) {
$configuration.CodeCoverage.Enabled = $false

$configuration.TestResult.Enabled = $true
$configuration.TestResult.OutputFormat = 'NUnit3'
}

$r = Invoke-Pester -Configuration $configuration
Expand Down

0 comments on commit 13af0b7

Please sign in to comment.