question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

testng-results.xml was not completely generated.

See original GitHub issue

TestNG Version

6.9.13.6 Java 1.8.0_74 linux x64

Actual behavior

As we run tests on Jenkins, and display test report by TestNG jenkins plugin. After update version of TestNG to 6.9.13.6, and version of java to 1.8.0_74, there are errors occured.

Logs of TestNG jenkins plugin:

TestNG Reports Processing: START Looking for TestNG results report in workspace using pattern: **/testng-results.xml Saving reports… Processing ‘/var/jenkins_home/jobs/api-test_payment_app-payment_0001_brood-qa13_daily/builds/679/testng/testng-results.xml’ Failed to parse XML: CDATA section started on line 1302 and column 26 was not closed (position: TEXT seen …<value>\n <![CDATA[org.testng.TestRun… @1302:44) caused by: java.io.EOFException: no more data available - expected end tags </value></param></params></test-method></class></test></suite></testng-results> to close start tag <value> from line 1301 and start tag <param> from line 1300 and start tag <params> from line 1299 and start tag <test-method> from line 1298 and start tag <class> from line 1289 and start tag <test> from line 8 and start tag <suite> from line 5 and start tag <testng-results> from line 2, parser stopped on TEXT seen …<value>\n <![CDATA[org.testng.TestRun… @1302:44 org.xmlpull.v1.XmlPullParserException: CDATA section started on line 1302 and column 26 was not closed (position: TEXT seen …<value>\n <![CDATA[org.testng.TestRun… @1302:44) caused by: java.io.EOFException: no more data available - expected end tags </value></param></params></test-method></class></test></suite></testng-results> to close start tag <value> from line 1301 and start tag <param> from line 1300 and start tag <params> from line 1299 and start tag <test-method> from line 1298 and start tag <class> from line 1289 and start tag <test> from line 8 and start tag <suite> from line 5 and start tag <testng-results> from line 2, parser stopped on TEXT seen …<value>\n <![CDATA[org.testng.TestRun… @1302:44

And open the testng-results.xml, the file is interrupted. In some jobs, the result file is generated completely. In some other jobs, the result file is interrupted on anywhere. It may end with incomplete CDATA “TestRunner”, or end with a “</class>” tag.

Diagnosis

I created a help class to test which part of logic is wrong.

public class XmlReportDiagnosis implements IReporter {

    @Override
    public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
        Logger.info(this.getClass(), "generateReport");
        TestNG testNG = TestNG.getDefault();
        if (!CollectionUtils.isEmpty(testNG.getReporters())) {
            for (Iterator<IReporter> iterator = testNG.getReporters().iterator(); iterator.hasNext();) {
                IReporter reporter = iterator.next();
                if (reporter instanceof XMLReporter) {
                    XMLReporter xmlReporter = (XMLReporter) reporter;
                    try {
                        Field rootBufferField = reporter.getClass().getDeclaredField("rootBuffer");
                        rootBufferField.setAccessible(true);
                        XMLStringBuffer rootBuffer = (XMLStringBuffer) rootBufferField.get(xmlReporter);
                        if (null != rootBuffer) {
                            Logger.info(this.getClass(), rootBuffer.toXML());
                        }
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                }
            }
        }
    }
}

In this class, it would print the rootBuffer, a field of XmlReport, to have a preview about whether the content in memory was generated completely. The test result is, the content in memory is correct.

So the cause was located to

Utils.writeUtf8File(config.getOutputDirectory(), FILE_NAME, rootBuffer, null /* no prefix */);

The last line of XmlReport.generateReport. I created a new Reporter and replace the output logic with lib apache-commons-lang. It works now.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:37 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cbeustcommented, Dec 8, 2016

It’s on Maven Central: http://repo1.maven.org/maven2/org/testng/testng/6.10/

– Cédric

On Thu, Dec 8, 2016 at 12:39 AM, alessio_demichelli < notifications@github.com> wrote:

@juherr https://github.com/juherr Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cbeust/testng/issues/1218#issuecomment-265684197, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFoojX7UPI-JzeYAE8suGEgEv7nMhx4ks5rF8I8gaJpZM4KgAGD .

0reactions
juherrcommented, Mar 1, 2018

You should try to ask your question on stackoverflow or maybe on the surefire issue tracker.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven project does not generate testng results within test ...
In Run from testNg.xml directly -By default in maven project html reports get created into test-output folder. In case we run from pom.xml...
Read more >
Problem with the automatically generated file "testng-results ...
The automaticly generated "testng-results. xml" file under "target/surefire-reports/" has the file encoding "UTF-8" and the first line in that file is "<? xml...
Read more >
Maven project is not generating TestNG results within the test ...
You can find the answer here. In Run from testNg.xml directly -By default in maven project HTML reports get created into a test-output...
Read more >
How To Generate TestNG Reports In Jenkins? - LambdaTest
Execute your Jenkins Job, and Now your Jenkins Selenium report or 'TestNG Results' would be visible in Your Jenkins Dashboard.
Read more >
Taking advantage of TestNG XML reports - Xray Documentation
if the "Test" attribute is used explicitly, then the Test must exist or else it will not be imported. Examples. Consider running some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found