gpt4 book ai didi

java - Jayway-放心执行测试用例时连接被拒绝错误

转载 作者:行者123 更新时间:2023-12-01 13:17:09 25 4
gpt4 key购买 nike

我正在使用 jayway 编写测试用例。我收到连接拒绝错误。

@RunWith(OrderitoJUnitRunner.class)
public class TestOrderService extends TestCaseSrs {

@Test
public void testFindUsingGroovyClosure() throws IOException
{
RestAssured.baseURI = "http://localhost";
String responseString = "Some Json";
String json = get("/test/Order/").asString();
JsonPath jp = new JsonPath(json);
String ssn = jp.get("customer.personId");
assertEquals("123456", ssn);
}
}

错误:

java.net.ConnectException: Connection refused: connect

Connect to localhost:8080 timed out. Connection will be retried using another IP address

我做错了什么吗?

最佳答案

我想说你没有在 localhost:8080 上监听任何内容

如果您将浏览器指向那里会发生什么?

如果您在 *nix 系统上运行,请尝试运行

netstat -an | grep 8080

有什么打印吗?如果没有,您就没有在 8080 上监听任何内容。

阅读 javadoc 总是值得的

http://docs.oracle.com/javase/7/docs/api/java/net/ConnectException.html

Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port).

希望这有帮助

关于java - Jayway-放心执行测试用例时连接被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22378114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com