testingtestngextentreports

Extent Report Spark Disregards Line Feed (New Line)


I added Extent Report 5 to tests and attached spark reporter to it, all in all it looks good, however I take result.getThrowable().getMessage() and it does not apply \n\r or \n in resulting index.html.

I know that it happens somewhere after flush is called, since in log list it still have the correct string with all characters. Also, if I send to fail() method getThrowable() itself it will be written correctly, but it have unnessessary data - exception and stack trace.

For reference my spark-config file looks like this:

{
  "documentTitle": "Extent Reports Title",
  "encoding": "utf-8",
  "js": "",
  "offlineMode": true,
  "protocol": "HTTPS",
  "reportName": "ExtentReportsName",
  "timelineEnabled": false,
  "timeStampFormat": "MMM dd, yyyy HH:mm:ss",
  "theme": "dark"
}

log have no new line


Solution

  • The only other way I know is to send your input wrapped in <pre></pre> tags.

    You can use the below technique which will keep your formatting intact.

    test.fail(result.getThrowable());