TestNG在Eclipse上运行时给出“拒绝连接”

时间:2010-10-20 22:52:18

标签: eclipse selenium-rc testng

我正在尝试使用Eclipse上的TestNG在Selenium-RC上运行Selenium测试。当我尝试运行测试时,我得到类似以下控制台输出的内容:

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

Selenium-RC服务器是否正在运行似乎并不重要。最新的TestNG插件安装在Eclipse中,我在类路径中包含了Selenium Java驱动程序。

1 个答案:

答案 0 :(得分:0)

问题是TestNG不知道正确的服务器位置。我在Eclipse中运行的本地Tomcat服务器位于工作空间元数据下。我添加了以下setUp()方法,其中my.local.host是我服务器的位置:

@BeforeTest
@Override
public void setUp() throws Exception {
   setUp("http://my.local.host:5555/", "*firefox");
}

添加此项后,测试用例成功运行。