'header'
method is used to validate the response headers. For example, below snippet
verifies response content type.
Example
given().header("Accept",
"application/json")
.when().get("api/v1/employees/")
.then().assertThat().statusCode(200).and()
.header("Content-Type",
"application/json;charset=UTF-8");
package com.sample.app;
import static io.restassured.RestAssured.given;
import org.junit.Test;
import io.restassured.RestAssured;
public class TestApp {
@Test
public void testApp() {
RestAssured.baseURI = "http://localhost:8080";
given().header("Accept", "application/json").when().get("api/v1/employees/").then().assertThat().statusCode(200)
.and().header("Content-Type", "application/json;charset=UTF-8");
}
}
No comments:
Post a Comment