{"action":"created","issue":{"url":"https://api.github.com/repos/cbeust/testng/issues/1218","repository_url":"https://api.github.com/repos/cbeust/testng","labels_url":"https://api.github.com/repos/cbeust/testng/issues/1218/labels{/name}","comments_url":"https://api.github.com/repos/cbeust/testng/issues/1218/comments","events_url":"https://api.github.com/repos/cbeust/testng/issues/1218/events","html_url":"https://github.com/cbeust/testng/issues/1218","id":185121833,"number":1218,"title":"testng-results.xml was not completely generated.","user":{"login":"ReinhardXu2007","id":11075559,"avatar_url":"https://avatars.githubusercontent.com/u/11075559?v=3","gravatar_id":"","url":"https://api.github.com/users/ReinhardXu2007","html_url":"https://github.com/ReinhardXu2007","followers_url":"https://api.github.com/users/ReinhardXu2007/followers","following_url":"https://api.github.com/users/ReinhardXu2007/following{/other_user}","gists_url":"https://api.github.com/users/ReinhardXu2007/gists{/gist_id}","starred_url":"https://api.github.com/users/ReinhardXu2007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReinhardXu2007/subscriptions","organizations_url":"https://api.github.com/users/ReinhardXu2007/orgs","repos_url":"https://api.github.com/users/ReinhardXu2007/repos","events_url":"https://api.github.com/users/ReinhardXu2007/events{/privacy}","received_events_url":"https://api.github.com/users/ReinhardXu2007/received_events","type":"User","site_admin":false},"labels":[{"id":211076254,"url":"https://api.github.com/repos/cbeust/testng/labels/Feature:%20report","name":"Feature: report","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-25T13:44:27Z","updated_at":"2016-12-07T10:10:01Z","closed_at":null,"body":"### TestNG Version\n\n6.9.13.6\nJava\n1.8.0_74 linux x64\n### Actual behavior\n\nAs we run tests on Jenkins, and display test report by TestNG jenkins plugin.\nAfter update version of TestNG to 6.9.13.6, and version of java to 1.8.0_74, there are errors occured.\n\nLogs of TestNG jenkins plugin:\n\n> TestNG Reports Processing: START\n> Looking for TestNG results report in workspace using pattern: **/testng-results.xml\n> Saving reports...\n> Processing '/var/jenkins_home/jobs/api-test_payment_app-payment_0001_brood-qa13_daily/builds/679/testng/testng-results.xml'\n> 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\n> 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\n\nAnd open the testng-results.xml, the file is interrupted.\nIn some jobs, the result file is generated completely.\nIn some other jobs, the result file is interrupted on anywhere. It may end with incomplete CDATA \"TestRunner\", or end with a \"&lt;/class&gt;\" tag.\n### Diagnosis\n\nI created a help class to test which part of logic is wrong.\n\n```\npublic class XmlReportDiagnosis implements IReporter {\n\n    @Override\n    public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {\n        Logger.info(this.getClass(), \"generateReport\");\n        TestNG testNG = TestNG.getDefault();\n        if (!CollectionUtils.isEmpty(testNG.getReporters())) {\n            for (Iterator<IReporter> iterator = testNG.getReporters().iterator(); iterator.hasNext();) {\n                IReporter reporter = iterator.next();\n                if (reporter instanceof XMLReporter) {\n                    XMLReporter xmlReporter = (XMLReporter) reporter;\n                    try {\n                        Field rootBufferField = reporter.getClass().getDeclaredField(\"rootBuffer\");\n                        rootBufferField.setAccessible(true);\n                        XMLStringBuffer rootBuffer = (XMLStringBuffer) rootBufferField.get(xmlReporter);\n                        if (null != rootBuffer) {\n                            Logger.info(this.getClass(), rootBuffer.toXML());\n                        }\n                    } catch (NoSuchFieldException e) {\n                        e.printStackTrace();\n                    } catch (IllegalAccessException e) {\n                        e.printStackTrace();\n                    } catch (Exception e) {\n                        e.printStackTrace();\n                    }\n                    break;\n                }\n            }\n        }\n    }\n}\n```\n\nIn this class, it would print the rootBuffer, a field of XmlReport, to have a preview about whether the content in memory was generated completely.\nThe test result is, the content in memory is correct.\n\nSo the cause was located to \n\n> Utils.writeUtf8File(config.getOutputDirectory(), FILE_NAME, rootBuffer, null /\\* no prefix */);\n\nThe last line of XmlReport.generateReport.\nI created a new Reporter and replace the output logic with lib apache-commons-lang. It works now.\n"},"comment":{"url":"https://api.github.com/repos/cbeust/testng/issues/comments/265407538","html_url":"https://github.com/cbeust/testng/issues/1218#issuecomment-265407538","issue_url":"https://api.github.com/repos/cbeust/testng/issues/1218","id":265407538,"user":{"login":"cantorio","id":7956191,"avatar_url":"https://avatars.githubusercontent.com/u/7956191?v=3","gravatar_id":"","url":"https://api.github.com/users/cantorio","html_url":"https://github.com/cantorio","followers_url":"https://api.github.com/users/cantorio/followers","following_url":"https://api.github.com/users/cantorio/following{/other_user}","gists_url":"https://api.github.com/users/cantorio/gists{/gist_id}","starred_url":"https://api.github.com/users/cantorio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantorio/subscriptions","organizations_url":"https://api.github.com/users/cantorio/orgs","repos_url":"https://api.github.com/users/cantorio/repos","events_url":"https://api.github.com/users/cantorio/events{/privacy}","received_events_url":"https://api.github.com/users/cantorio/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T10:10:01Z","updated_at":"2016-12-07T10:10:01Z","body":"Unfortunately, no. All I can say is we have 5500+ tests running via maven. All results are present in testng-results.xml, except last four lines. So the common structure of file is following: \r\n```xml\r\n<testng-results>\r\n\t<suite name=\"SomeSuite\">\r\n\t\t<test name=\"SomeTest\">\r\n\t\t\t<class name=\"SomeClass\">\r\n\t\t\t\t<test-method status=\"PASS\">\r\n\t\t\t\t\t<params>\r\n\t\t\t\t\t\t<param index=\"0\">\r\n\t\t\t\t\t\t\t<value>\r\n\t\t\t\t\t\t\t\t<![CDATA[public %TESTNAME%]]>\r\n\t\t\t\t\t\t\t</value>\r\n\t\t\t\t\t\t</param>\r\n\t\t\t\t\t</params>\r\n\t\t\t\t\t<reporter-output>\r\n\t\t\t\t\t</reporter-output>\r\n\t\t\t\t</test-method> <!-- This is the last line, present in testng-results.xml -->\r\n\t\t\t</class> <!-- Missing line -->\r\n\t\t</test>\t<!-- Missing line -->\r\n\t</suite> <!-- Missing line -->\r\n</testng-results> <!-- Missing line -->\r\n```\r\nI tried to reproduce the issue with one simple test, but everything was OK."}}
{"actor":{"display_login":"cantorio"}}