top of page
swatij81

Run JMeter and generate HTML Dashboard Report from command line (non GUI mode)

The Apache JMeter is open-source software, a 100% pure Java application designed for performance testing.

The GUI mode of JMeter is perfect for adding and editing new configuration elements, thread groups, and samplers. However, the GUI mode consumes a lot of memory and resources while running the recorded script. GUI mode is not recommended for heavy load testing.


Once your Test Plan is ready, use CLI mode (Command-line mode previously called Non-GUI mode) to run it for the Load Test. Using CLI mode, you can generate a CSV file containing results and have JMeter generate an HTML report at end of load test. By executing script at command line it can be easily integrated with other systems (Jenkins/Other CI tools).


In this blog, we will see how to run JMeter test from command line and generate an HTML report.


Prerequisite:


Apache JMeter installed on your system.

A test plan built and available in JMeter.


You can follow my previous blog to install JMeter, start JMeter in GUI mode and build a test plan.



Steps to run JMeter in command line mode:

  1. Open command prompt.

  2. Go into JMeter’s bin folder

  3. Enter the following Command to run JMeter test


jmeter -n -t <location of jmeter script> -l <location of result file>
  • -n specifies the JMeter is to run in cli mode.

  • -t specifies name of JMX file that contains the Test Plan.

  • -l specifies name of result file to log sample results to. The result file must not exist or be empty.

Screenshot of JMeter test plan, which we will run from command line:


JMeter Test Plan
JMeter Test Plan

Run JMeter script from command line

Go to the specified location of result file and see if the csv file (in this case, file CSVTest1.csv) is created.



Now open the CSV file to check whether the results are logged into it.


CSVTest1.csv file


Generating Report Dashboard:


JMeter supports dashboard report generation to get graphs and statistics from a test plan. The dashboard generator reads and processes samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.

Lets see how to use the dashboard generator.


Option 1: You can create a dashboard report at the end of test case execution.


Command to run JMeter script and generate a dashboard report is as follows:


jmeter -n -t <location of jmeter script> -l <location of result file> -e -o <location of output folder>
  • -e specifies generate report dashboard after load test

  • -o specifies output folder where to generate the report dashboard after load test. Folder must not exist or be empty.

Screenshot of JMeter test plan, which we will run from command line and generate report.


JMeter Test Plan

Command to run JMeter test and generate HTML report

Go to the specified location and check whether the CSV test result file (CSVTestResult.csv) and output folder (Dashboard) are created.


"CSVTestResult.csv" file and output folder "Dashboard" created at specified location

CSVTestResult.csv

To view the dashboard report, go to Dashboard folder and open index.html file.



HTML Dashboard Report

Chart of type "Over Time"

This report provides different metrics e.g. APDEX table, request summary graph showing the Success and failed requests percentage, different charts etc. Toleration threshold and Frustration threshold values are configurable.


Configuring Dashboard Generation:


Dashboard generation uses JMeter properties to customize the report. All report generator properties can be found in file reportgenerator.properties. To customize these properties, you should copy them in user.properties file and modify them.


reportgenerator.properties file inside JMeter/bin folder

Go to JMeter/bin folder, you will find user.properties file. Open that file.


user.properties file inside JMeter/bin folder

If needed, you can change the tolerated and satisfied threshold values in user.properties file. Then run your JMeter at command line and generate a dashboard report. Now those updated threshold values will be reflected in the dashboard.


Option 2: Create a dashboard report from a standalone CSV file.


Suppose, you have already executed JMeter test from command line and generated CSV result. You can create a dashboard from CSV file using below command.


jmeter -g <location of csv file> -o <location of output folder>

We will use the csv file generated on run of JMeter in command line mode at the beginning of this blog.


Run command to generate dashboard from CSV file

Note: My CSV file and output folder are at the same location (JMeter/bin), so I have just specified their names.


Go to the specified location and check if output folder (Report) is created. Go inside the output folder and you can see HTML report file i.e. index.html file.


index.html file inside Report folder

Screenshot of HTML report:


Conclusion:


GUI mode of JMeter is not recommended for heavy load testing. GUI mode should only be used for creating the test script, CLI mode (NON GUI) must be used for load testing.


Following points covered in this blog:

  • Steps to Run JMeter in command line mode

  • Generating report dashboard: generate the report at end of a load test or on demand.


Happy Load Testing !!

38,445 views

Recent Posts

See All
bottom of page