Validate method for Request

Dahun Yoo·2020년 12월 19일
0
post-thumbnail

Static import

REST-Assured 를 사용하기 위해서는, Maven/Gradle에서 dependencies 선언을 해준 다음,
아래와 같이 Static import를 해줍니다.

io.restassured.RestAssured.*
io.restassured.matcher.RestAssuredMatchers.*
org.hamcrest.Matchers.*

REST-Assured 는 객체를 생성하지 않고, static하게 사용할 수 있습니다.

또한, REST-Assured 라이브러리를 사용하게 되면, 주요 response를 핸들링하기 위한 추가 라이브러리인 JsonPathXmlPath가 포함되어 있습니다.


Validate method

기본적으로, given, when, then 이라는 3개의 메소드를 사용합니다. 이 것은 BDD Framework에서 많이 사용되는 Gherkin의 주요 문법이기도 합니다.

또한, 대부분의 기능은 method chain에 의해서 어떠한 흐름을 가지고 사용할 수 있으며, 가독성이 높은 편입니다.

RestAssured.baseURI = "https://www.google.com";

Response response = given().queryParam("key", "value")
        .header("Content-Type", "application/json")
        .body( "{" + "\"website\": \"http://google.com\"",
                "\language\": \"French-IN\"\n" +
                "}"
        )
.when().post("/maps/api/place/add/json")
.then().statusCode(200);

given() ~ when() 까지는 request. then() 은 response를 나타냅니다.

profile
QA Engineer

0개의 댓글