Logging - Lab 1
1. Add the request and response filters to the BaseTest class
Steps
- Open the
BaseApiConfiguration
class located atsrc/test/java
in thecom.workshop
package - At the end of the method add:
- the
RestAssured.filters()
method new RequestLoggingFilter()
as the first parameternew ResponseLoggingFilter()
as the second parameter
- the
- Run the tests
Expected results
- The test output will show all the requests and responses for each test executed
Solution
Click to see...
public class BaseApiConfiguration {
@BeforeAll
static void mainConfiguration() {
RestAssured.baseURI = "http://localhost";
RestAssured.basePath = "/api/v1";
RestAssured.port= 8088;
RestAssured.config = RestAssuredConfig.newConfig().
jsonConfig(JsonConfig.jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL));
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter());
}
}