You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encounterd an error with the force:apex:test:run and force:apex:test:report commands, where the output creation of a JUNIT xml generates an invalid XML. This is because messages containing a double-quote don't get escaped.
We are using this command in an automated pipeline in Azure, where we want to publish the testresults, but Azure cannot parse the XML because it is not valid.
I have first updated SFDX before submitting this issue:
# sfdx update
sfdx-cli: Updating CLI from 7.132.0-6621068 to 7.142.1-05bbd4a... done
sfdx-cli: Updating CLI... done
sfdx-cli: Updating sf... done
Steps to reproduce
Create the following test class:
@IsTest
public class TestJunit {
@IsTest
public static void generateIncorrectOutput() {
throw new CustomException('This message contains "Double quotes"');
}
class CustomException extends Exception {
}
}
If you try to parse this XML (for instance using sfdx force:apex:test:run -n TestJunit -r junit | xmllint -) you will get:
-:23: parser error : attributes construct error
<failure message="TestJunit.CustomException: This message contains "
^
-:23: parser error : Couldn't find end of Start Tag failure line 23
<failure message="TestJunit.CustomException: This message contains "
^
-:23: parser error : Opening and ending tag mismatch: testcase line 22 and failure
"><![CDATA[Class.TestJunit.generateIncorrectOutput: line 6, column 1]]></failure
^
-:24: parser error : Opening and ending tag mismatch: testsuite line 3 and testcase
</testcase>
^
-:25: parser error : Opening and ending tag mismatch: testsuites line 2 and testsuite
</testsuite>
^
-:26: parser error : Extra content at the end of the document
</testsuites>
^
The text was updated successfully, but these errors were encountered:
Hello,
I encounterd an error with the
force:apex:test:run
andforce:apex:test:report
commands, where the output creation of a JUNIT xml generates an invalid XML. This is because messages containing a double-quote don't get escaped.We are using this command in an automated pipeline in Azure, where we want to publish the testresults, but Azure cannot parse the XML because it is not valid.
I have first updated SFDX before submitting this issue:
Steps to reproduce
Create the following test class:
Run the testclass with JUNIT output
sfdx force:apex:test:run -n TestJunit -r junit
This generates:
If you try to parse this XML (for instance using
sfdx force:apex:test:run -n TestJunit -r junit | xmllint -
) you will get:The text was updated successfully, but these errors were encountered: