Search code examples
apiautomated-testspostmanhttp-response-codesnewman

Capturing Postman requests in a report


I was checking on Postman and newman and how to automate the api testing. I have checked on assertions and the report generations that show results of assertion failures and pass status. We can check the status code by writing a an assertion. But is there a way where in we can capture the request and response directly for an api and generate a report that shows (say) 3 apis were tested and the requests agve 200 for first call 201 fro second an d then 400 for third without writing any assertions. The overall result will show request url and corresponding response code for the api.

This will be helpful in a way when we run a collection and then can see a html report stating the response code corresponding to the request url.

Thank you all in advance for your patience reading and extremely helpful insight to the problem. Thank You.


Solution

  • this already exists in Postman, through its command line interface Newman.

    Have a look here and here as well. You'll be able to set options, depending on the kind of reports you want. Personaly I can use newman in TFS and get JUnit style reports that fit for my continuous integration purpose. You can generate also HTML reports.

    Check the different options.

    To handle response data, have a look here : This takes place in the Tests tab of the Postman request, though You can obtain informations about HTTP code (responseCode.code), description (responseCode.detail), etc. You can also parse the JSON body to get more information

    var jsonData = JSON.parse(responseBody);
    

    You can output this data in the console