我刚接触rest-assured和Java,想要进行一个非常基本的测试,检查API的响应是否为200 ok。 请问有人能告诉我,在下面的脚本中我需要改变什么来传递多个头部Id、Key和ConId吗?
import org.junit.Test;
import com.jayway.restassured.*;
import com.jayway.restassured.http.ContentType;
import static org.hamcrest.Matchers.*;
import static com.jayway.restassured.RestAssured.*;
public class APIresponse
{
public static void main(String[] args)
{
APIresponse apiresponse = new APIresponse();
apiresponse.response();
}
@Test
public void response ()
{
baseURI="http://testme/api/";
given().
header("Id", "abc").
param("Key", "NuDVhdsfYmNkDLOZQ").
param("ConId", "xyz").
when().
get("/uk?Id=DT44FR100731").
then().
contentType(ContentType.JSON).
body("response.code", equalTo("200"));
}
}
expect().statusCode(200),log().ifError().given()......
语句,或从此链接中选择一个测试响应头的示例:https://github.com/jayway/rest-assured/blob/master/examples/rest-assured-itest-java/src/test/java/com/jayway/restassured/itest/java/HeaderITest.java - parishodak