Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-57

Invalid characters in XML reports

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 2.4
    • JUnit 3.x support
    • None

    Description

      Surefire (or possibly Xpp3Dom?) should check for invalid characters in JUnit output and escape or mask them to ensure valid XML reports. This applies to all characters outside the allowed range defined in the XML spec (http://www.w3.org/TR/REC-xml/#NT-Char).

      I have a JUnit test case that uses assertEquals on strings. In some situations, the string to compare against the reference may be completely garbled and contain things such as null characters, which then show up in the assertion failure message ("expected X but was Y") and consequently in the XML reports.

      Here's a simple test case to trigger the problem:

      public class InvalidCharactersTest extends TestCase {
      public void testStrings()

      { String expected = "abc"; String actual = "abc" + '\u0000'; assertEquals(expected, actual); }

      }

      The resulting Surefire XML report contains the null character as is and is therefore not valid XML. Running the Surefire Reports plugin then fails with a parsing error.

      Attachments

        1. TEST-com.acme.test.ResourceLoaderTest.xml
          5 kB
          Khai Do
        2. pom.xml
          2 kB
          Khai Do

        Activity

          People

            Unassigned Unassigned
            klaus.brunner Klaus Brunner
            Votes:
            3 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: