简体   繁体   English

如何在ExtentReports日志中记录RestAssured请求和响应信息日志

[英]How to log RestAssured Request and Response information log in ExtentReports logs

I am using rest-assured lib and extent report for reporting, 我正在使用可放心的lib和扩展区报告进行报告,

ValidatableResponse reponseManualLead = given().header("Accept", "application/json")
                .contentType("application/json").header("Authorization", access_token)
                .body(requestBody).log().body().when()
                .put(losdevUrl + "/endUrl").then().log().all();

log().all() : Pritn log of request/reponse in console log , I need that to be log in extentreport , can we do that. log()。all():控制台日志中请求/响应的原始日志,我需要将其登录到extentreport中,我们才能做到这一点。

ExtentTestManager.getTest().log(LogStatus.INFO, "Response is:<br>" + "here");

The recommended usage to include JSON request/response is via MarkupHelper as in the documentation: http://extentreports.com/docs/versions/4/java/#markup-helpers-codeblock 推荐的用法包括文档中的MarkupHelper来包括JSON请求/响应: http : MarkupHelper

Markup m = MarkupHelper.createCodeBlock(json, CodeLanguage.JSON);
test.pass(m);

// shorthand
test.pass(MarkupHelper.createCodeBlock(json, CodeLanguage.JSON));

The code block will be prettified and display like so: 该代码块将被美化并显示如下:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM