Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run single Selenium tests or test classes #502

Open
2 of 6 tasks
ghost opened this issue Jun 19, 2020 · 2 comments
Open
2 of 6 tasks

Cannot run single Selenium tests or test classes #502

ghost opened this issue Jun 19, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 19, 2020

Problem Statement

If I try to run a Selenium test class (or single test) via right-click -> Run as -> testNG or using a run configuration, I get:

[RemoteTestNG] detected TestNG version 6.10.0
org.testng.TestNGException: java.net.ConnectException: Connection refused: connect
	at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:325)
	at org.testng.remote.AbstractRemoteTestNG.initialize(AbstractRemoteTestNG.java:137)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:98)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
	at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:647)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1304)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1270)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:264)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1161)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1045)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:959)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
	at org.testng.xml.XMLParser.parse(XMLParser.java:39)
	at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)
	at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)
	at org.testng.xml.Parser.parse(Parser.java:170)
	at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:305)
	... 4 more

This works for suite XML files, though. I.e. using "Run as > TestNG" on a TestNG XML file starts running the selenium tests indicated in the file, just as expected.

I debugged the failing test execution and saw that, at some point, the code checks whether or not the DTD's URL is http://testng.org/dtd (note the "http"), in which case the DTD is not fetched from internet. Because this is the last version of the plugin, the DTD of the "magically created" XML suite uses https, therefore it does not match the http URL, so the logic tries to download the DTD file and fails.

The machine is running behind a corporate proxy, which I think may be the cause for the error, but the proxy settings in Eclipse are correct and I can download plugins, update, etc, without issues.

Any relate message in "Error Log" view

"Windows -> Show View -> Others -> Error Log"

No further errors appear in the error log.

The Dependency Management tool for your project

  • Maven
  • Gradle
  • Ant
  • [?] Eclipse Buildpath (aka. Use "TestNG Library" for your project in Eclipse)
    Buildpath is installed, but the project is imported as a "Gradle Project"

Operating System

  • Windows
  • Linux
  • OSX

What follows is, I think, a separate bug, and I'd be happy to file it separately if required

I tried to "force" using http://testng.org/dtd by providing an XML template:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Absence Management" thread-count="1" group-by-instances="false" verbose="1" allow-return-values="false" parallel="none" data-provider-thread-count="10" junit="false" configfailurepolicy="skip" preserve-order="true" skipfailedinvocationcounts="false">
  <listeners>
    <listener class-name="org.testng.reporters.FailedReporter"/>
  </listeners>
  <test verbose="2" name="Default test">
   
  </test> <!-- Default test -->
</suite> <!-- Absence Management -->

, which is basically the same XML generated by the plugin, but changing the DTD's URL to http instead of https. This causes an error:

An internal error occurred during: "Launching ManageOccupationQualifiersOnServiceAgreement".
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]

Adding -Dtestng.dtd.http=true to the JVM arguments in "Window > Preferences > TestNG > Run/Debug" has no effect, i.e. I think the plugin is not properly adding the JVM arguments when running a TestNG test.

@missedone
Copy link
Collaborator

could you try with JVM arg -Djava.net.preferIPv4Stack=true

@ghost
Copy link
Author

ghost commented Jun 22, 2020

Hi @missedone ,

The argument is ignored (or has no effect), just like with -Dtesting.dtd.http=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant