22
votes

I have been using JMeter in GUI mode for composing all the test cases required for load testing my service but for actual testing I need to execute tests in non-GUI mode. How do I save the results of Aggregate report in csv file using command-prompt.

Thanks in advance.

5

5 Answers

13
votes

Just as alternative: you may do this directly from the Aggregate Report listener.

1. set filename/template for results file:

resultsFile = ${__property(user.dir)}${__BeanShell(File.separator,)}result_${__time(yyyyMMdd-HHmmss)}.csv

2. configure Aggregate Report listener as shown below:

enter image description here

CSV-file generated in this case will differ from generated via GUI/"Save Table Data" one.

If it is not acceptable you'll better use method with JMeterPluginsCMD from previous answer:

java -jar JMeterPluginsCMD.jar --generate-csv aggregateResults.csv --input-jtl testResults.jtl --plugin-type AggregateReport
8
votes

Use JMeterPluginsCMD tool with Plugin Type = AggregateReport

6
votes

1. Save result file

Specify a result file to saved into in View Results Tree or View Table Results (in CSV or XML). Ex: out/test-results.csv or with CLI argument -JTEST_RESULTS_FILE=out/test-results.csv

2. Convert to report

Convert the result file into an aggregate report:

$ java -jar CMDRunner.jar  --tool Reporter --generate-csv aggregateResults.csv --input-jtl out/test-results.csv --plugin-type AggregateReport

If you use brew, CMDRunner is located at:

/usr/local/Cellar/jmeter/2.13/libexec/lib/ext/CMDRunner.jar
0
votes

With the help from the above answer, I wrote a simple bash script to automate the work of generating aggregated result .csv file using .jtl files

You can put this script in the folder where .jtl files are in , and just run the script in that directory. Then, it will put all the aggregated reports(.csv files) in the aggregate_report directory in the same directory

#! /usr/bin/env bash

echo "Generating reports..."
command_runner="/opt/apache-jmeter-2.13/lib/ext/CMDRunner.jar"
output="aggregate_report"
count=0

mkdir $output

for sample_file in *.jtl
do
        ((count++))
        filename="${sample_file%.*}"
        echo "Converting $filename"
        java -jar $command_runner --tool Reporter --generate-csv ${output}/${filename}.csv --input-jtl ${filename}.jtl --plugin-type AggregateReport
done

echo "$count files were converted."

note: change the command_runner variable accordingly with your CMDRunner.jar location

0
votes
  1. Download JMeterPluginsCMD.

  2. Move jmeter-plugins-manager-0.13.jar into /bin/libs/ext of your JMeter.

  3. Open JMeter, go to Options > Plugins Manager.
  4. Install the following plug-ins:
    • Synthesis Report
    • Command line graph plotting tool
  5. Run this command from your JMeter's /bin folder: ./JMeterPluginsCMD.sh --tool Reporter --generate-csv test.csv --input-jtl input.jtl --plugin-type AggregateReport