Install restAssured to log all requests and responses around the world
I want to enable logging for all restAssured query responses and default queries.
That's what I'm doing:
RestAssured.requestSpecification = new RequestSpecBuilder().
setBaseUri("api").
setContentType(ContentType.JSON).
build().
log().all();
RestAssured.responseSpecification = new ResponseSpecBuilder().
build().
log().all();
requestSpecification works fine, but with responseSpecification I get:
The logging cannot be configured because the request specification is undefined. You can abuse the API.
I really don't want to use log (). all () after each one.
+9
source to share
3 answers
Can anyone help me here. i see the same error when i try to enter the infrastructure public static RequestSpecification getRequestSpecification () {
REQUEST_BUILDER = new RequestSpecBuilder();
REQUEST_BUILDER.setBaseUri(Path.BASE_URI);
REQUEST_SPEC = REQUEST_BUILDER.build();
return REQUEST_SPEC;
}
public static ResponseSpecification getResponseSpecification() {
RESPONSE_BUILDER = new ResponseSpecBuilder();
RESPONSE_BUILDER.expectStatusCode(200);
RESPONSE_BUILDER.expectResponseTime(lessThan(3L), TimeUnit.SECONDS);
RESPONSE_SPEC = RESPONSE_BUILDER.build();
//RESPONSE_SPEC = RESPONSE_SPEC.log().ifError();
//RESPONSE_SPEC.log().ifError();
return RESPONSE_SPEC;
}
0
source to share