【发布时间】:2018-03-25 14:33:48
【问题描述】:
我想使用 testNG 的 Reporter.log() 方法将在控制台中打印的请求数据记录到 testNG 报告文件中,该方法需要字符串输入。以下是我的请求规范:
private RequestSpecification getRequestSpec(ContentType requestbodytype, ContentType responsetype) {
return RestAssured.given().log().everything().contentType(requestbodytype).accept(responsetype);
}
protected Response get(String resourceURI, ContentType requestbodytype, ContentType responsetype, boolean enableUrlEncoding) {
Response rs = null;
rs = getRequestSpec(requestbodytype, responsetype).when().get(resourceURI);
Reporter.log(rs.print());
return rs;
}
我想将以下内容记录到测试日志文件以及执行此调用后我将收到的响应
Request method: GET
Request URI: http://localhost:port/url
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=application/json, application/javascript, text/javascript
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body: <none>
谁能帮我解决这个问题。
谢谢
【问题讨论】:
标签: java rest logging testng rest-assured