I need the testng plugin to generate results as xml version 1.0 instead of 1.1


(cpatrick) #1

We have the following in our build…gradle:

test {

// enable TestNG support (default is JUnit)

useTestNG()

}

The results file all build a header like the following:

[lt]?xml version=“1.1” encoding=“UTF-8”?[gt]

This is causing the Jenking testng report plugin to fail with the following error

org.xmlpull.v1.XmlPullParserException: only 1.0 is supported as <?xml version not ‘1.1’ (position: START_DOCUMENT seen <?xml version=“1.1”… @1:19)

Is there some setting I can change to convince gradle to generate the testng results as version=1.0?


(Cameron Fieber) #2

Here is a complete build.gradle that demonstrates the issue:

apply plugin: ‘java’

repositories {

mavenCentral()

}

test {

useTestNG()

}

dependencies {

testCompile ‘org.testng:testng:6.8.5’

}

src/test/java/MyTest.java:

import org.testng.annotations.Test;

public class MyTest {

@Test

public void testNothing() {

throw new RuntimeException(“fail”);

}

}

produces build/test-results/TEST-MyTest.xml:

<?xml version=“1.1” encoding=“UTF-8”?>

<testsuite name=“MyTest” tests=“1” failures=“1” errors=“0” timestamp=“2013-08-21T22:36:46” hostname=“lgml-cfieber” time=“0.0060”>

<properties/>

<testcase name=“testNothing” classname=“MyTest” time=“0.0060”>


(Justin Ryan) #3

Just pointing out that the xml output is perfectly fine JUnit output, which was the source of our confusion. We were having Jenkins process the xml reports as TestNG, which fails.


(rburgst) #4

was there any result for this? Having the same problem.


(Justin Ryan) #5

Is it really a problem? You’re still running TestNG, the results just happen to be in JUnit format. All the data is still there. Once we know what the format was, it wasn’t a problem for us anymore.


(rburgst) #6

You are correct, I probably didn’t read or understand the answer. I needed to change from the jenkins TestNG publisher to the JUnit publisher and everything worked.