Reputation: 309
I am using rest-assured lib and extent report for reporting,
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.
ExtentTestManager.getTest().log(LogStatus.INFO, "Response is:<br>" + "here");
Upvotes: 3
Views: 4747
Reputation: 527
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
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:
Upvotes: 1