TestNG gives "Connection Refused" while running on Eclipse
I'm trying to run Selenium tests开发者_运维问答 with Selenium-RC using TestNG on Eclipse. When I try to run a test, I get something like the following console output:
org.testng.TestNGException:
Cannot establish connection: 127.0.0.1:1613
at org.testng.remote.strprotocol.StringMessageSenderHelper.connect(StringMessageSenderHelper.java:94)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:71)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:144)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.testng.remote.strprotocol.StringMessageSenderHelper.connect(StringMessageSenderHelper.java:56)
... 2 more
It doesn't seem to matter whether the Selenium-RC server is running or not. The latest TestNG plugin is installed in Eclipse, and I have the Selenium Java driver included in the classpath.
The problem was that TestNG was unaware of the correct server location. I have a local Tomcat server running in Eclipse located under the workspace metadata. I added the following setUp() method, where my.local.host
is the location of my server:
@BeforeTest
@Override
public void setUp() throws Exception {
setUp("http://my.local.host:5555/", "*firefox");
}
After adding this the test case ran successfully.
精彩评论