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.

Suite.xml files attempt to make web request when suite references standard TestNG DTD using HTTP

See original GitHub issue

TestNG Version

7.3.0

Expected behavior

Suite file referencing http://testng.org/testng-1.0.dtd should NOT attempt to load the DTD URL, and therefore should not require -Dtestng.dtd.http=true.

Actual behavior

The http version of the DTD URL is unrecognized by Parser.isUnRecognizedPublicId, and therefore TestNG complains that it needs the testng.dtd.http property to download the DTD from the URL.

Is the issue reproductible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

The following suite file is generated by IntelliJ 2020.2.3, when I right-click to run a class:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default Suite">
  <test name="myproject">
    <classes>
      <class name="example.TestClass"/>
    </classes>
  </test> <!-- myproject -->
</suite> <!-- Default Suite -->

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30

github_iconTop GitHub Comments

1reaction
krmahadevancommented, Nov 10, 2020

@robbytx - Thanks for confirming that the fix works fine.

At the risk of being rude, I can’t help but observe that this regression could have been avoided if this type of behavior were covered by a unit test, and I’ll note that your fix does not contain a unit test, so this behavior could be regressed in the future.

Sure. Feedback taken. On the flip-side of not sounding blunt, adding a unit test for this would be a bit more involved effort, since

  • I would have to figure out a mechanism that detects if the classloading was resorted to.
  • I would also need to figure out a mechanism that would intercept a call to the internet and then fake it.

I didn’t have the time. Also I self concluded that this is not a functionality that is going to be changing a lot over time and so I did a quick cost effort weighing in and intentionally skipped adding a test.

But all said and done, if you have any ideas on how to go about adding a test for this, please feel free to contribute. If it’s via a PR, it’s even more merrier. We will be more than happy to get it vetted out and merged.

0reactions
robbytxcommented, Nov 10, 2020

Yes, it is working now – thank you for fixing it.

At the risk of being rude, I can’t help but observe that this regression could have been avoided if this type of behavior were covered by a unit test, and I’ll note that your fix does not contain a unit test, so this behavior could be regressed in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 - Stack Overflow
I solved it by adding the secure flag in the URL as follows: "https://testng.org/testng-1.0.dtd". Regards.
Read more >
TestNG Example: How To Create And Use TestNG.Xml File
Let's run the XML file. Run the test by right click on the TestNG XML file and select Run As => TestNG Suite....
Read more >
Documentation - TestNG
A suite is represented by one XML file. It can contain one or more tests and is defined by the <suite> tag. A...
Read more >
TestNG 7.4.0 - Released !
xml files attempt to make web request when suite references standard TestNG DTD using HTTP; GITHUB-2385: Make @Listeners can work for ...
Read more >
Jetty : The Definitive Reference - Eclipse
war exists, only the XML is deployed (which may use the WAR in its configuration). If you have a standard web application, you...
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