Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/functions/TestResults.NUnit3.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ function Write-NUnit3TestCaseAttributes {
$XmlWriter.WriteAttributeString('asserts', '1') # required attr, so hardcoding 1:1 per testcase
}

function Write-NUnit3OutputElement ($Output, [System.Xml.XmlWriter] $XmlWriter) {
function Format-CDataString ($Output) {

# The characters in the range 0x01 to 0x20 are invalid for CData
# (with the exception of the characters 0x09, 0x0A and 0x0D)
# We convert each of these using the unicode printable version,
Expand Down Expand Up @@ -572,8 +573,13 @@ function Write-NUnit3OutputElement ($Output, [System.Xml.XmlWriter] $XmlWriter)
}

$outputString = $o -join [Environment]::NewLine
return $outputString
}


function Write-NUnit3OutputElement ($Output, [System.Xml.XmlWriter] $XmlWriter) {
$XmlWriter.WriteStartElement('output')
$XmlWriter.WriteCData($outputString)
$XmlWriter.WriteCData((Format-CDataString $output))
$XmlWriter.WriteEndElement()
}

Expand All @@ -585,12 +591,12 @@ function Write-NUnit3FailureElement ($TestResult, [System.Xml.XmlWriter] $XmlWri
$XmlWriter.WriteStartElement('failure')

$XmlWriter.WriteStartElement('message')
$XmlWriter.WriteCData($result.FailureMessage)
$XmlWriter.WriteCData((Format-CDataString $result.FailureMessage))
$XmlWriter.WriteEndElement() # Close message

if ($result.StackTrace) {
$XmlWriter.WriteStartElement('stack-trace')
$XmlWriter.WriteCData($result.StackTrace)
$XmlWriter.WriteCData((Format-CDataString $result.StackTrace))
$XmlWriter.WriteEndElement() # Close stack-trace
}

Expand All @@ -604,7 +610,7 @@ function Write-NUnitReasonElement ($TestResult, [System.Xml.XmlWriter] $XmlWrite
if ($result.FailureMessage) {
$XmlWriter.WriteStartElement('reason')
$XmlWriter.WriteStartElement('message')
$XmlWriter.WriteCData($result.FailureMessage)
$XmlWriter.WriteCData((Format-CDataString $result.FailureMessage))
$XmlWriter.WriteEndElement() # Close message
$XmlWriter.WriteEndElement() # Close reason
}
Expand Down