每当运行测试用例时都会获取java.net.ConnectException

问题描述 投票:0回答:1
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");
    }

}
java json api testng rest-assured-jsonpath
1个回答
0
投票

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

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

应该是:

.get("http://restapi.demoqa.com/utilities/weather/city/Mumbai")
© www.soinside.com 2019 - 2024. All rights reserved.