I'm using testng maven and selenium to run my tests, currently I have the following testng.xml file
Looks like the problem is with the &listeners and &classes lines, If I replace those lines with the xml content that I have on the referenced files it runs fine. I have used this in a previous project and it worked fine, not sure why I'm getting this error.
<?xml version = "1.0" encoding = "UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" [ <!ENTITY listeners SYSTEM "listeners.xml"> <!ENTITY classes SYSTEM "classes.xml"> ]> <suite name="Local Execution" verbose="5"> &listeners; <test name="Core Integration Tests" time-out="800000"> <groups> <run> <include name="failed"/> </run> </groups> &classes; </test> </suite>
Listener.xml content is like
<listeners> <listener class-name="com.myclass.Listeners.TestListener"/> </listeners>
And classes file is
<classes> <class name="com.orders.tc_class1"/> <class name="com.orders.tc_class2"/> </classes>
This is part of the error I'm getting
org.testng.TestNGException: TestNG by default disables loading DTD from unsecure Urls. If you need to explicitly load the DTD from a http url, please do so by using the JVM argument [-Dtestng.dtd.http=true] at org.testng.xml.TestNGContentHandler.resolveEntity(TestNGContentHandler.java:102)
DTD stands for "Document Type Definition". xml to be compatible with. Suite in Testng is represented by tag, and can have multiple attributes passed. It can contain one or more tests, here we have two tests. Test tag in Testng is represented by and can contain one or more TestNG classes.
TestNG provides an option of tracing the exception handling of code. You can test whether a code throws a desired exception or not. Here the expectedExceptions parameter is used along with the @Test annotation.
Yes, that's the default behavior of TestNG and I had introduced it through that pull request to fix the bug https://github.com/cbeust/testng/issues/2022
To set the JVM arguments in intelliJ, choose Run > Edit Configurations
, and add this JVM argument in the VM options section after -ea
(which would be there by default.
For more information on editing configurations, please refer to the official documentation here
Added screenshot for easy to find in Intellij
Argument value
-ea -Dtestng.dtd.http=true
If the above does not work do at template level, this will fix it, which is
Run--> Edit configuration --> template --> testng
Just change all yours
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"
on https:
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With