getgauge / html-report

HTML report generation plugin for Gauge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Add XML and/or JSON messages to HTML Report with Syntax Highlighting

alpha1592 opened this issue · comments

This is a feature request for the HTML Reports

We have several web services soap/rest tests and we like to put the request and response messages into the html report for testers to review. it also serves as good audit record to see the exact request and response that was sent out and received. We use Gauge.writeMessage("xmlPayload"); in Java to put the xml and/or json payloads into the report. However, we do a lot of pre-processing to ensure the xml is escaped, EOL characters are \r\n or others are converted to </br> to name a few. It would be nice if we could simply add xml and/json messages with a method call and that method could cleanup the text and pre-format it, which would yield some special formatting on the html report with support for syntax highlighting and potentially line numbers.

in Gauge.java

Definition:
Gauge.attachXMLPayload(String heading, String xml);

Usage:
Gauge.attachXMLPayload("My Soap Request Message", xmlPayload);

It Should look something like this in the report..... line numbers are not shown here, but would be nice to have...


My Soap Request Message

<soap:Envelope>
  <soap:Header>
    <soap:Body>
        <request>hello</request>
        <tx_id>43253452345235</tx_id>
        <data name="some-name" type="type">this is some random data</data>
    </soap:Body>
  </soap:Header>
</soap:Envelope>

and for json, use something like this...

Definition:
Gauge.attachJSONPayload(String heading, String json);

Usage:
Gauge.attachJSONPayload("This is my JSON Response Message", payload);


This is my JSON Response Message

{
  "name": "username",
  "dob": 1999-02-53,
  "gender": "F"
}

Attached pictures below show line numbers with syntax highlighting...

My Soap Request Message

json

This is my JSON Response Message

xml

As per our discussion, we will be adding options to the existing writeMessage API.

For example in java, we will be overloading the existing Gauge.writeMessage API to take a enum of values such as json, xml etc. i.e., API will look like Gauge.writeMessage(<json payload string>, JSON)

In languages such as JavaScript, we will be taking a options object instead i.e., the api will look like gauge.message(<json payload string>, {"type": "json"}

Excellent. Thank you.
The reports will syntax highlight with line numbers for the XML/JSON payloads?

Any idea when this will be ready?

Unfortunately the there are a few things of higher priority than this at the moment. However pull requests are welcome!

Closing this as an old issue. However, any PR's to fix this will be merged.