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 &class
To fix this for all tests run from IntelliJ only, can update the TestNG template with the -Dtestng.dtd.http=true
vm option. Will need to delete existing test runs or manually add the vm option (I'd just remove them). All the tests run following the template change will have the mentioned vm option.
Run/Debug Configurations
-> Edit Configurations
-> Templates
-> TestNG
Details Exception is as follows:- org.testng.TestNGException: TestNG by default disables loading DTD from unsecured 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]
To fix the Exception it needs to set the JVM arguments. To set the JVM arguments in Eclipse:
I came across this error recently and tried the solutions given above but still got the error. Setting JVM arguments is the solution for this problem anyways as shown in above answers but I added one more step and it fixed my issue.
I changed the arguments in TestNG Configuration as shown below (added step):
I also changed the arguments in LoginTests.testSuccessfullLogin. (This step would only be necessary if you have ran the program with the issue. Otherwise if you are running the program for first time, it will create this configuration with the same arguments as in TestNG configuration.)
I also noticed that if you haven't done the second step mentioned above, it will create a new configuration called LoginTests.testSuccessfullLogin(1) with the changed arguments in order to run the tests.
Just to avoid confusion and make it easier for some one who is new to the Config edit option etc attaching a snap for getting it done in intellij.
So as answered by- Mr Krishnan M. : Go to Edit Config for your Cucumber TestNGRunner class, then we have to add another argument to the VM options as below-
How to Edit Run Config
How to add >VM argument: "-Dtestng.dtd.http=true"
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
Another option, if want it work for all the tests, regardless where you run them from, set the option in the pom by setting a system property. Add the following for maven-surefire-plugin
and maven-failsafe-plugin
<configuration>
<systemPropertyVariables>
<testng.dtd.http>true</testng.dtd.http>
</systemPropertyVariables>
</configuration>