38

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.

dacracot
  • 22,002
  • 26
  • 104
  • 152

9 Answers9

51

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

Krishna
  • 393
  • 2
  • 3
  • 18
dacracot
  • 22,002
  • 26
  • 104
  • 152
  • You'll find under "Config" that XML can save several more data elements then CSV, which may be useful depending on your needs. – BlackGaff Jun 09 '11 at 14:58
  • 4
    Hi dacracot, which of the "fields" are you referring to? tx – Ittai Jul 20 '11 at 06:29
  • Thanks, I couldn't figure out how to save to a file from the Jmeter GUI. Didn't realize the test had to be run first. – Mike R Nov 27 '13 at 04:08
  • 3
    Also, you must input the **full path** for the filename. A relative path wouldn't work for some reason. – Pacerier Oct 06 '15 at 10:07
10

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.

jai
  • 109
  • 2
  • 1
    Sure you can save a csv file here too, but is the csv file the same one though? Do the two files match? – Pacerier Oct 06 '15 at 10:06
4

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/

user1022143
  • 43
  • 1
  • 5
4

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>

shashankS
  • 1,043
  • 1
  • 11
  • 21
1

maybe it can be useful for you http://www.2min2code.com/articles/jmeter_intro/simple_data_writer

sara.flo
  • 63
  • 1
  • 1
  • 8
1

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

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

Sanjay Bhatia
  • 47
  • 2
  • 11
0

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".

Ram pravin
  • 21
  • 3
0

Open the user.properties file. You might have the value jmeter.save.saveservice.output_format=xml

Change it to

jmeter.save.saveservice.output_format=csv

You can generate the csv file and Output folder by below steps :

1.Open Terminal

2.Navigate to bin folder of Jmeter

sh jmeter.sh -n -t your_JMX_File.jmx -l your_output_csv_file.csv -e -o yourTargetedOutputFolder

Chetan Yeshi
  • 71
  • 1
  • 4