testng: TestNG XML not valid with DTD @ http://testng.org/testng-1.0.dtd
Please see stackoverflow link here: http://stackoverflow.com/questions/42772424/testng-xml-not-valid
I am getting issues with the XML not meeting the DTD.
TestNG Version
Tried on 6.11 and 6.9.11
Expected behavior
XML should be valid with DTD.
Actual behavior
Getting the error: 1: 3 The markup declarations contained or pointed to by the document type declaration must be well-formed.
Is the issue reproductible on runner?
- Shell
- Maven
- Gradle
- Ant
- Eclipse
- IntelliJ
- NetBeans
Test case sample
I have some generated TestNG XMLs that worked for a long time, but recently they are invalid when I run them through Java’s SAXParser and through http://www.xmlvalidation.com/
Example generated XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="1" verbose="2" name="TestNG Forum" parallel="tests">
<test name="TestNG Test0" preserve-order="false">
<parameter name="device" value="58f56054954b6b3e323a3405fc49023eb1569a98"/>
<packages>
<package name="output"/>
</packages>
</test> <!-- TestNG Test0 -->
</suite> <!-- TestNG Forum -->
Example XML from TestNG’s site @ http://testng.org/doc/documentation-main.html
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Nopackage" >
<classes>
<class name="NoPackageTest" />
</classes>
</test>
<test name="Regression1">
<classes>
<class name="test.sample.ParameterSample"/>
<class name="test.sample.ParameterTest"/>
</classes>
</test>
</suite>
EDIT:
SAXParser error:
[Fatal Error] testng-1.0.dtd:1:3: The markup declarations contained or pointed to by the document type declaration must be well-formed.
org.xml.sax.SAXParseException; systemId: http://testng.org/testng-1.0.dtd; lineNumber: 1; columnNumber: 3; The markup declarations contained or pointed to by the document type declaration must be well-formed.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
at com.video.recorder.XpathXML.parseXML(XpathXML.java:42)
at com.cucumber.listener.ExtentCucumberFormatter.feature(ExtentCucumberFormatter.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:290)
at com.sun.proxy.$Proxy17.feature(Unknown Source)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:161)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:414)
at org.testng.internal.thread.ThreadUtil$1.call(ThreadUtil.java:52)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 1
- Comments: 34 (9 by maintainers)
I curl the dtd file and saw a message that it was moved to https://testng.org/testng-1.0.dtd. So I just changed the url in my in the testng xml to https😕/testng.org/testng-1.0.dtd instead of http😕/testng.org/testng-1.0.dtd, now it’s working on my end.
I’m having this problem when using TestNG 7.3.0 in Eclipse. Where do you find the “TestNG xml” … is that somehow generated by Eclipse?
Confirm, it’s broken again today (yesterday worked fine). curl shows redirect info:
If I change the link in xml to https the validation is passed.
@brtu In fact, I proposed 2 different solutions:
ISuiteListenershould avoid parsing the suite and a custom dtd resolver should allow to parse the suite without problem.Yes, it looks like xerces doesn’t follow redirection. But you can use your own dtd resolver: https://github.com/cbeust/testng/blob/master/src/main/java/org/testng/xml/TestNGContentHandler.java#L89-L116
BTW, what are you trying to do? If you need to access to
XmlSuitefrom your code, you may create anISuiteListenerwhich store theXmlSuitein a static variable and you will be able to use it in your code.@brtu It is saying that DTD https://raw.githubusercontent.com/cbeust/testng/master/src/main/resources/testng-1.0.dtd is not valid but I don’t see why.
Ping @cbeust @krmahadevan