Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable REST-Assured debug printing to console?

By default Rest-Assured is printing too much debug data to the console.

Can anyone tell how can I disable it?

like image 965
Dotan Raz Avatar asked Nov 12 '17 09:11

Dotan Raz


1 Answers

You can tell RestAssured what you want to log like this:

RestAssured
        .given()
        .log().ifValidationFails(LogDetail.ALL, true)
        .body(body)
        .post("URL")
        .then()
        .log().ifValidationFails(LogDetail.ALL, true)
        .extract()
        .jsonPath()
        .getObject("body", DTO.class)

and if something go wrong it print request/response info to console.

You can choose which part of request/response to log by specify value from io.restassured.filter.log.LogDetail as ifValidationFails() first param.

If you want log request or response all the time use this

RestAssured
            .given()
            .log().<all|body|headers|etc>()
            .body(body)
            .post("URL")
            .then()
            .log().<all|body|headers|etc>()
            .extract()
            .jsonPath()
            .getObject("body", DTO.class)

log() after given() will config request logging

log() after then() will config response logging

You can find more helpful info here https://github.com/rest-assured/rest-assured/wiki/Usage#logging

like image 75
Sergey Avatar answered Sep 20 '22 18:09

Sergey