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:

2 Likes

I mean

Question 1:
My GET API is fetching data in to POSTMAN in JSON format.Can I download that fetched data through a CSV file?

Question 2: The GET API fetches a maximum of 150k records from a table.Is there a way that I can increase this?

Apologies for the confusion.

Please let me know if you want to discuss more on this.

Thanks,
Lokesh.

1 Like

Your questions are very interesting but hard to answer and you did not give very much context. I would advise that you create two separate questions, in case they donโ€™t directly relate to the question being asked here.

1 Like

Thank you!

I will give a try and letโ€™s see how it works.