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
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