HttpLoggingPlugin implements CukesHttpPlugin, CukesPlugin { @Override public void beforeRequest(RequestSpecification requestSpecification) { if (!(requestSpecification instanceof FilterableRequestSpecification)) { throw new IllegalArgumentException("Cannot retrieve configuration from: " + requestSpecification); } final FilterableRequestSpecification filterableRequestSpecification = (FilterableRequestSpecification) requestSpecification; final RequestLogSpecification logSpec = filterableRequestSpecification.log(); final List<LogDetail> logDetails = parseLogDetails(world.get(LOGGING_REQUEST_INCLUDES, DEFAULT_REQUEST_INCLUDES)); details: for (LogDetail detail : logDetails) { switch (detail) { case ALL: logSpec.all(); break details; case BODY: logSpec.body(); break; case COOKIES: logSpec.cookies(); break; case HEADERS: logSpec.headers(); break; case METHOD: logSpec.method(); break; case PARAMS: logSpec.parameters(); break; case URI: logSpec.uri(); break; } } } @Inject  HttpLoggingPlugin(GlobalWorldFacade world, RestAssuredConfiguration config); @Override void beforeAllTests(); @Override void afterAllTests(); @Override void beforeScenario(); @Override void afterScenario(); @Override void beforeRequest(RequestSpecification requestSpecification); @Override void afterRequest(Response response);  }
@Test public void testOutputStream() throws UnsupportedEncodingException { when(world.get(LOGGING_REQUEST_INCLUDES, "")).thenReturn("all"); RequestSpecification specification = RestAssured.given() .config(config.getConfig()) .baseUri("http: .param("q", "hi"); plugin.beforeRequest(specification); specification.get(); String requestLog = testOut.toString("UTF-8"); assertThat(requestLog, is(EXPECTED_RESULT)); }