2

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");
Cod
  • 179
  • 1
  • 12
  • Possible duplicate of https://stackoverflow.com/a/55189800/4762087 – Vamsi Ravi Mar 20 '19 at 19:32
  • U can use this [artifact](https://github.com/grasshopper7/rest-assured-extent-report-plugin) and [article](https://ghchirp.tech/3791/) for creating a Spark Report, just by adding a filter to rest calls. – Grasshopper Jan 01 '22 at 06:37

1 Answers1

1

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:

enter image description here

foursyth
  • 527
  • 1
  • 3
  • 10