java—在代理内部工作时,testng返回连接超时

gwo2fgha  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(740)

当我连接到vpn/proxy testng时,在intellij中运行测试时返回以下错误:

org.testng.TestNGException: java.net.ConnectException: Connection timed out: connect
    at org.testng.TestNG.parseSuite(TestNG.java:354)
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:374)
    at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:39)
    at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.base/sun.nio.ch.Net.connect0(Native Method)
    at java.base/sun.nio.ch.Net.connect(Net.java:503)
    at java.base/sun.nio.ch.Net.connect(Net.java:492)
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
    at java.base/java.net.Socket.connect(Socket.java:648)
    at java.base/java.net.Socket.connect(Socket.java:597)
    at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
    at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:341)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:362)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1261)
    at

你知道我怎么设置testng的代理吗?还是另一种解决方案?

92dk7w1h

92dk7w1h1#

要解决此问题,必须为测试指定vm参数:

-Dhttp.proxyHost=your_host
-Dhttp.proxyPort=your_port
-Dhttps.proxyHost=your_host
-Dhttps.proxyPort=your_port

相关问题