32
votes

I've created my jMeter test which make 20,000 HTTP requests. I've included the "View Results in Table" listener. After running the test, I would like to save the table results to a CSV file.

8

8 Answers

40
votes

Ok, I figured it out. Least intuitive UI ever... type into the field the file name you want saved to, start the test. This creates and writes to the file.

9
votes

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.

4
votes

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/

2
votes

There are many ways you can push for the results. This is CLI way:

STEPS: 1. download the latest jmeter version

  1. Extract in your desired directory. For example, extract to /tmp/
  2. Now, default output file format will be csv. No need to change anything or specify in the CLI command.
  3. Save jmx file from UI console. Say, you have saved on examples directory for example:
  4. Now, Run the command from CLI console: jmeter -n -t examples/test.jmx -l examples/output.csv

Now, if you want to change the default format, check the following parameter in jmeter.properties file: jmeter.save.saveservice.output_format=xml

Now if you run the command, ./jmeter -n -t examples/test.jmx -l examples/output.jtl output get stored in xml format.

Now, make the request on multiple server(Additional info query for good knowledge): We can specify host and port as argument/tags in CLI command

./jmeter -n -t examples/test.jmx -l examples/output.csv -JHOST=<HOST> -JPORT=<PORT>

1
votes

You can save the result in any of the listener, below are the steps -

Go to Thread--> Add --> Listener --> View result tree(or any other listener) Picture here

Here you can save the file by giving the file name as abc.csv and go for configure, there you need to uncheck xml file and click on csv file. Also the file result abc.csv is by default saved in the bin folder of the apache-jmeter tool.

1
votes

1.Open Terminal

2.Navigate to bin folder of Jmeter

3.Run jmeter -n –t (path of jmx file)/test.jmx -l(path to save your result)/testresults.csv

-n-It specifies JMeter is to run in non-gui mode

-t-Name of JMX file that you want to run

-l: Name of csv file to log results

0
votes

In ViewResultsTree there will be an option "write results to a file/Read from a file" under that in the FileName field enter the path where the file needs to be saved along with the filename as "fileName.csv". Click on configure then uncheck "save as XML Option" and check "save as csv".