Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log restassured traffic

I'd like to know if there is a way of logging all the calls and responses (url + payload) processed by restassured.

THe finality would be to have a "debug" test log with all the calls and traffic logged.

Of course I could issue calls to the logger in my own code, but I'd prefear to set this behavour globally and not to add logger calls in all my test methods.

Thanks for any pointers

like image 898
devlearn Avatar asked Oct 30 '13 21:10

devlearn


2 Answers

I am posting an example:

 Response response = given().
                    queryParam("apiKey", "abc123").
                    queryParam("code", code).
                    queryParam("type", type).
                    contentType("application/json").
                    log().all().
                    when().
                    get(url).
                    then().
                    contentType("application/json").
                    statusCode(200).
                    extract().response();
like image 92
Mircea Stanciu Avatar answered Oct 07 '22 06:10

Mircea Stanciu


Set log().all() for your response and it will be okay.

like image 27
Gergely A. Avatar answered Oct 07 '22 06:10

Gergely A.