Skip to content

Cater for nested CDDATA in XML reporters #643

@lwasylow

Description

@lwasylow

Current reporter when printing xml don't escape CDDATA when it's part of the string being printed e.g. failure message. This causing a xml to break.
Sample test:

create or replace package check_junit_reporting is
      --%suite()

      --%test(Test with ccdata)
      procedure test_do_stuff;

    end;
create or replace package body check_junit_reporting is
      procedure test_do_stuff is
      begin
        ut.expect('1').to_equal('<![CDATA[some stuff]]>');;
      end;
    end;

And result

<testsuites tests="1" skipped="0" error="0" failure="1" name="" time=".078591" >
<testsuite tests="1" id="1" package="check_junit_reporting"  skipped="0" error="0" failure="1" name="check_junit_reporting" time=".078326" >
<testcase classname="check_junit_reporting"  assertions="2" skipped="0" error="0" failure="1" name="Test with ccdata" time=".077445"  status="Failure">
<failure>
<![CDATA[
Actual: '1' (varchar2) was expected to equal: '<![CDATA[some stuff]]>' (varchar2) 
"at "UT3_TESTER.CHECK_JUNIT_REPORTING.TEST_DO_STUFF", line 4 ut.expect('1').to_equal('<![CDATA[some stuff]]>');
"
]]>
</failure>
</testcase>
</testsuite>
</testsuites>

And when you validate
XML Parsing Error: not well-formed
Line Number 9, Column 52:

Since CDDATA is not really something we can escape the only solution I found was to use ]]]]><![CDATA[>

<testsuites tests="1" skipped="0" error="0" failure="1" name="" time=".078591" >
<testsuite tests="1" id="1" package="check_junit_reporting"  skipped="0" error="0" failure="1" name="check_junit_reporting" time=".078326" >
<testcase classname="check_junit_reporting"  assertions="2" skipped="0" error="0" failure="1" name="Test with ccdata" time=".077445"  status="Failure">
<failure>
<![CDATA[
Actual: '1' (varchar2) was expected to equal: '<![CDATA[some stuff]]>' (varchar2) 
"at "UT3_TESTER.CHECK_JUNIT_REPORTING.TEST_DO_STUFF", line 4 ut.expect('1').to_equal('<![CDATA[some stuff]]]]><![CDATA[>');
"
]]>
</failure>
</testcase>
</testsuite>
</testsuites>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy