Set accept and contentType to json by default for restassured

时间:2017-06-07 11:06:02

标签: java rest-assured

How could I set the accept and contentType to json projectwide in my rest tests?

    given()
        .accept(ContentType.JSON)
        .contentType(ContentType.JSON)

This will reduce quite some repetitive code

1 个答案:

答案 0 :(得分:1)

RestAssured.requestSpecification = new RequestSpecBuilder()
        .setContentType(ContentType.JSON)
        .setAccept(ContentType.JSON)
        .build();