How do I save my Apache jMeter results to a CSV file?

Solution 1:

Ok, I figured it out. Least intuitive UI ever... Browse the file name as you want from file system using browse option OR fill the absolute file name in 'Filename' field and then start the test. This creates and writes to the file.

Refer attached image. It is possible to choose CSV, XML and JTL format as required. Filename should be complete path.

View Result in Table

Solution 2:

Just add Aggregate Report to your test plan by choosing Thread->Listener->AggregateReport Run your Test.When it is completed aggregate report will displays the information about the test runs.Here there is an option to save the report as csv.

Solution 3:

The way to do it is using beanshell. You need to download the library and add it to the lib folder. Then create a BeanShell sampler with your request and add code. Something like the following would do:

import org.apache.jmeter.services.FileServer;

// Static elements or calculations
String Variable1 = vars.get("ValueForVariable1AsMentionedInJMeterScript");
String Variable2 = vars.get("ValueForVariable1AsMentionedInJMeterScript");
String Variable3 = vars.get("ValueForVariable1AsMentionedInJMeterScript");


// Open File(s)
f = new FileOutputStream(FileServer.getFileServer().getBaseDir()+"\\NameOfTheCSVFile.csv", true); 
p = new PrintStream(f); 

// Write data to file 
p.println(Variable1 + "," + Variable2 + "," + Variable3);

// Close File(s)
p.close();f.close();

//this is for veryfying your code
return jsonOutput;

ValueForVariable1AsMentionedInJMeterScript is the name of your variable in your script.

For more info please see this page: http://hellotestworld.com/2013/05/02/write-a-file-from-a-jmeter-script/