Java 记录可靠的流量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19694306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Log restassured traffic
提问by devlearn
I'd like to know if there is a way of logging all the calls and responses (url + payload) processed by restassured.
我想知道是否有一种方法可以记录 restassured 处理的所有调用和响应(url + 有效负载)。
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
感谢您的任何指点
回答by devlearn
Sorry dumb question (or issue with my vision), everything is documented under:
抱歉愚蠢的问题(或我的愿景有问题),所有内容都记录在:
回答by Gergely A.
Set log().all() for your response and it will be okay.
为您的响应设置 log().all() 就可以了。
回答by Mircea Stanciu
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();