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/