Export Test Results to CSV

Hi,

I am new to Postman and API testing world. I was able to create some basic tests and my team is looking for how long each api takes to respond. They want me to export the results to csv file so they can sort it by the response time to see which ones are taking the longest to respond. How can I easily fulfill that requirement using Postman? Question 1: Is there any way to automatically write the test results at the end of the test run to a csv file using Javascript in the Collection Test?
Question 2: We are planning to integrate the tests with the builds. That means when somebody pushes a build, these tests will be run first using Newman. Not sure if the test results (in JSon format) will be automatically saved somewhere. If so can we do the conversion Json to CSV using New man after the test?
Following information is needed in the csv file - Test name, request URL, pass/fail with the response time.

I greatly appreciate your help.
Thanks,
MJP

@rmantripragada While there is no inbuilt export to CSV option, what you’ve described can be accomplished using Newman as a library: https://github.com/postmanlabs/newman#newmanrunevents

The idea here is that Newman provides an event emitter interface, which allows users to write highly complex handlers to account for virtually any use case. In this case, you can use the test event (see the links above for more context), which will let you handle test data in real time as the collection runs.

1 Like

Thanks @kunagpal ,
It’s help me a lot. Right now, I can export results with some types such as HTML, XML. I also can customer HTML template to render as format I want. Here are some notes of mine:

+ Syntax:
newman run [FileNameJSon] -e [Environment] --reporters cli,[Support_Type] --reporter-[Support_Type]-export [Output_File].[Support_Type]
Example:
newman run 1_Automated_APIs.postman_collection.json -e SIT.postman_environment.json --reporters cli,html --reporter-html–export outputfileHTML.xml
+ Customize template HTML
newman run [FileNameJSon] -e [Environment] --reporters cli,html --reporter-html-template template-default.hbs --reporter-html-export [Output_File].html
Example:
newman run 1_Automated_APIs.postman_collection.json -e SIT.postman_environment.json --reporters cli,html --reporter-html-template template-default.hbs --reporter-html-export outputfilehtml1.html

Note: You can download template-default.hbs by the following path https://github.com/postmanlabs/newman/tree/develop/lib/reporters/html

A little late to the party but you can try out the newman-reporter-csv package:

1 Like