BUG: Non UTF-8 byte sequence in junitreports XML

66 views
Skip to first unread message

Alexey Krylov

unread,
Apr 19, 2013, 11:24:03 AM4/19/13
to testn...@googlegroups.com
Hi,

I'm using testng with Jenkins running on Tomcat. Unfortunately, TestNG Results Plugin for Jenkins suffers from multiple bugs and usability issues, so I have to use JUnit Reports plugin running off junitreports produced by testng. But testng produces a invalid UTF-8 encoded xml reports with raw character data coming from assertions. For example, the following assertion

public void testOne() {
    char ch = (char)0xC0;
    Assert.assertEquals(ch, 'x');
}

will cause generated junitreports/TEST-ReportTest.xml to include non  UTF-8 encoded string. The fix is really just one line in JUnitReportReporter.java:


diff --git a/src/main/java/org/testng/reporters/JUnitReportReporter.java b/src/main/java/org/testng/reporters/JUnitReportReporter.java
index a3122d1..237b32e 100644
--- a/src/main/java/org/testng/reporters/JUnitReportReporter.java
+++ b/src/main/java/org/testng/reporters/JUnitReportReporter.java
@@ -171,7 +171,7 @@ public class JUnitReportReporter implements IReporter {
       xsb.pop("testsuite");

       String outputDirectory = defaultOutputDirectory + File.separator + "junitreports";
-      Utils.writeFile(outputDirectory, getFileName(cls), xsb.toXML());
+      Utils.writeUtf8File(outputDirectory, getFileName(cls), xsb.toXML());
     }

 //    System.out.println(xsb.toXML());
 

Thank you
--Alexey

Cédric Beust ♔

unread,
Apr 19, 2013, 10:50:33 PM4/19/13
to testn...@googlegroups.com
Hi Alexey,

I just fixed this in master, thanks!


-- 
Cédric



--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+...@googlegroups.com.
To post to this group, send email to testn...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages