每当我 运行 我的测试用例时得到 java.net.ConnectException
Getting java.net.ConnectException whenever I run my test case
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")
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")