java - 每当我运行测试用例时都会出现 java.net.ConnectException

标签 java json api testng rest-assured-jsonpath

package restAssuredTesting;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;

import org.testng.annotations.Test;

public class DemoProjectForGet {

    @Test
    public void getWhetherDetails() {
        given()
        .when()
        .get("http:/restapi.demoqa.com/utilities/weather/city/Mumbai")
        .then()
        .statusCode(200)
        .statusLine("HTTP/1.1 200 OK")
        .assertThat().body("City", equalTo("Mumbai"))
        .header("Content-Type", "application/json");
    }

}

最佳答案

您在 http://中缺少斜线。

.get("http:/restapi.demoqa.com/utilities/weather/city/Mumbai")

应该是:

.get("http://restapi.demoqa.com/utilities/weather/city/Mumbai")

关于java - 每当我运行测试用例时都会出现 java.net.ConnectException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59634343/

相关文章:

java - 将 JButton 外观更改为自定义图片

java - 类方法未执行正确的计算

java - 将平面 JSON 结构转换为对象并添加另一个属性

javascript - D3.js 分组条形图多次绘制数据

api - Flask 未从 HTTP POST 接收数据

api - TLS sslv3 握手错误

ruby - Google Developer API key 和 YouTube API

java - 编辑文本属性不显示日期

java - 从资源中的图像设置图标图像

java - Android 从 Json 对象解析字符串值