【发布时间】:2020-02-07 06:00:36
【问题描述】:
我正在使用带有 RestAssured 框架的 TestNG 来测试 RestAPI。
执行到这一行的那一刻,httpRequest.request,它会抛出连接超时错误
我在那一行有什么遗漏吗?它没有抛出任何语法错误。
import org.testng.annotations.BeforeMethod;
import static io.restassured.RestAssured.ntlm;
import static io.restassured.RestAssured.basic;
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.http.Method;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
public class RestApi_Incidents {
@BeforeMethod
public void beforeMethod() {
System.out.println("before method");
}
@Test
void GetIncidentAPI(){
try{
RestAssured.baseURI = "https://xxx/api/data/v8.2";
RestAssured.port = 80;
RestAssured.basePath = "/incident";
RestAssured.authentication = basic("userid", "pwd!");
//RestAssured.authentication = ntlm("uid", "pws!", null, "uat");
RequestSpecification httpRequest = RestAssured.given();
Response response =httpRequest.get();
}
catch (Exception ex){
System.out.println(ex.toString());
}
}
}
【问题讨论】:
标签: testng rest-assured