如何在 ExtentReports 日志中记录 RestAssured Request 和 Response 信息日志

How to log RestAssured Request and Response information log in ExtentReports logs

我正在使用放心的库和范围报告进行报告,

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() :控制台日志中 request/reponse 的 Pritn 日志,我需要它来登录 extentreport,我们可以这样做吗?

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

包含 JSON request/response 的推荐用法是通过 MarkupHelper,如文档中所示:http://extentreports.com/docs/versions/4/java/#markup-helpers-codeblock

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

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

代码块将美化后显示如下: