Запуск jmeter из командной строки windows

Для запуска JMeter из командной строки необходимо сначала убедиться, что Java установлена на вашем компьютере. Затем следуйте этим шагам:

  1. Скачайте JMeter с официального сайта Apache JMeter (https://jmeter.apache.org/download_jmeter.cgi) и распакуйте архив.

  2. Откройте командную строку на вашем компьютере.

  3. Перейдите в папку с распакованным JMeter.

  4. Для запуска JMeter из командной строки используйте команду:

jmeter.sh

для Linux или MacOS

jmeter.bat

для Windows

  1. После запуска JMeter из командной строки вы увидите GUI интерфейс JMeter, где вы сможете создавать и запускать тестовые планы.

Дополнительно, JMeter также поддерживает non-GUI режим, который позволяет запускать тесты без интерфейса. Для запуска JMeter в non-GUI режиме используйте команду:

jmeter -n -t [путь к тестовому плану] -l [путь к файлу результатов тестирования]

где -n указывает на non-GUI режим, -t [путь к тестовому плану] указывает на путь к вашему тестовому плану, а -l [путь к файлу результатов тестирования] указывает на путь к файлу, куда будут записаны результаты тестирования.

To run a JMeter test from the command line, we need to follow the steps below:

  1. Open a terminal or command prompt.
  2. Navigate to the directory where the JMeter executable file is located.
    • In our case, the file is inside the JMeter’s bin directory /opt/jmeter/bin. If we have added the directory that contains the jmeter command to our system’s PATH environment variable, we can run the jmeter command from any directory.

      Note: To find the full path of our saved file in the current directory and its subdirectories, we can use the find command in the following manner: find . -name "test.jmx" where test.jmx is the name of our executable file.

  3. Enter the following command to run the test:
    jmeter -n -t /path/to/your/test.jmx -l /path/to/save/results.csv
    

Let’s take a look at how we can do this.

Run the test.jmx file

To add the directory (/opt/jmeter/bin) to the PATH environment variable permanently (not just for the current session) from the terminal, enter the following command:

echo 'export PATH="$PATH:/opt/jmeter/bin"' >> ~/.bashrc

source ~/.bashrc

  • Line 1: The echo command appends the export PATH="PATH:/opt/jmeter/bin"' >> ~/.bashrc line to the end of the .bashrc file[object Object] in the user’s home directory (~ refers to the user’s home directory). This sets the PATH variable for the current user and allows the jmeter command to be executed from anywhere in the terminal.

  • Line 2: The source ~/.bashrc reloads the .bashrc file in the current shell session so that the updated PATH variable is available for the current session.

To gain hands-on experience, please run the above commands in the following terminal to add the bin directory to the PATH environment variable.

If we want to run the test.jmx file and place the test results in the result.csv file that we have already created in the JMeter’s bin folder, we enter the following commands:

# command to run the JMeter test

jmeter -n -t ./opt/jmeter/bin/test.jmx -l result.csv

# command to display the contents of the CSV file (result.csv) in a human-readable format

csvtool readable result.csv

In the code above:

  • -n specifies JMeter to run the test in a non-GUI (CLI) mode

  • -t specifies the path to the JMeter test file (.jmx)

  • -l specifies the path to save the test results file

  • csvtool displays the .csv file in the terminal in a human-readable format with headers for each column

We have included the commands above in the terminal below. Click the terminal to see the tests being executed.

Updated February 21, 2023

JMeter Command Line

Introduction to JMeter Command Line

JMeter is an open-source tool used to perform load and performance testing on the application. There are two ways to use JMeter: the graphical user interface and command line mode. JMeter provides different functionality when we use command line mode, such as we can generate the CSV or say that the XML file consists of the output of test execution. In other words, we can say that it stores the result of the HTML report. Normally JMeter, by default, provides the summary of load testing after the execution as well as we can also see the real-time output of test execution as per our requirements.

What is the JMeter Command-Line?

Apache JMeter is an open-source testing application. JMeter capacities to examine and gauge the presentation of web applications with an assortment of different administrations. In addition, the GUI method of JMeter is ideal for adding and altering new arrangement components, string gatherings, and samplers, which allows you to see various audience members helping with troubleshooting.

Nonetheless, the GUI mode has a constraint that dials back the CPU while running the recorded content. Assuming we are running different audience members in content, it influences the JMeter execution. The content should be run in non-GUI mode to defeat such a circumstance. There is an advantage to driving more demands each second out of JMeter in non-GUI mode.

A command-line interface (CLI) processes orders to a PC program as lines of text. The program that handles the connection point is an order line translator or order line processor.

Working frameworks execute an order line interface in a shell for intelligent admittance to working framework capacities or administrations.

We will execute the JMeter Tests in Non-GUI mode. However, before that, we want to comprehend why we want to execute the Test In Non-GUI mode.

Typically when we execute the Request in the Non-GUI Mode, it will send a few solicitations to the server and get the reaction, and again it will require some investment to produce the reports and view the outcomes to the client. So it will interact with the UI of some sort or another Level.

So we cannot get the Actual outcome when we send the solicitation and help a reaction through UI. So we run the JMeter Test in order briefly to keep away from that circumstance.

Now let’s see why we need to use command line mode.

  • Expanding strings (after a specific limit) because of which JMeter crashes in the GUI mode.
  • For serious test situations (ex: shopping application: login-view item put on truck view tab eliminate item take care of bill), JMeter consumes memory and CPU, which might influence your experimental outcomes.
  • To build JMeter capacities, for example, to get more demands each second.

How to Run JMeter Command-Line?

Now let’s see how we can run JMeter on command line mode.

First, we need to open the command line prompt window, as shown in the following screenshot.

Command line prompt Window

In the second step, we need to go into the bin folder of JMeter. After that, we need to enter the command,

JMeter -n –t test.jmx -l testresults.jtl

We need to set the different parameters in the above command as follows.

  • n is used to specify the JMeter run test into a non-GUI mode that is command line mode.
  • t Is used to specify the name of the JMX file that contains the plan of a test, and it depends on the user.
  • l It is used to specify the name of the JMeter text log file and consists of the log result.
  • j It is used to specify the name of JMeter log files.

After executing the above command, we see the generated result in the specified location in CSV format; here, we can add any listener as per our requirement, but we need to open JMeter into a GUI mode for that purpose.

JMeter Command Line Configuration

Now let’s see how we can configure the command line mode of JMeter as follows.

In the above point, we already discussed how to run the JMeter command line mode, but if we want to run JMeter for distributed testing, we need to do some settings on our local machine.

  1. First, we need to ensure we installed the updated version of JMeter.
  2. After that, we need to make some changes to the JMeter properties file for IPs and slaves; in this step, we also ensure the master and slave are located on the same subnet.
  3. Now we need to execute the JMeter server on every slave, so for that purpose, we need to execute the bat file of JMeter from the bin folder.
  4. Report generation and reaming all things are the same.

Example of JMeter Command Line

Now let’s see the example for better understanding as follows.

First, we need to add the test plan into the JMeter, as shown in the following screenshot.

JMeter Command Line Example 1

We need to add the listener to view the output, as shown in the following screenshot.

Add listener Example 2

Now save the test plan, minimize the current window and execute the below-mentioned command.

JMeter -n -t D:\Software\apache-JMeter-5.4.1\apache-JMeter-5.4.1\bin\ View Results Tree.jmx -l D:\Software\apache-JMeter-5.4.1\apache-JMeter-5.4.1\bin\result.csv

Explanation

In the above command, we specify all parameters such as the name of the test plan, location of the test plan, where we need to store the result of the test plan, etc. Then, we can make the changes in the above command as per our requirements. We illustrated the final output of the above command by using the following screenshot.

JMeter Command Line Example 3

After executing the above command, the CSV file generated, as shown below, is as follows.

CSV file Example 4

Now we need to open that file to see the output of the test plan, as shown in the following screenshot.

JMeter Command Line Example 5

Conclusion

We hope from this article you learn more about the JMeter command line. From the above article, we have taken in the essential idea of the JMeter command line and see the representation and example of the JMeter command line. Furthermore, this article taught us how and when to use the JMeter command line.

Recommended Articles

This is a guide to JMeter Command-Line. Here we discuss the definition and how to run and configure JMeter Command-Line along with the example. You may also look at the following articles to learn more –

  1. Python Command-line Arguments
  2. JMeter Version
  3. Postgres Command-Line
  4. JMeter Alternatives

In my Previous blog, I give you the steps for how to check HTTP request using Jmeter. Now, this blog is to check, how can we check JMeter test or script using Command line.

  • Why Do we exactly go to non-GUI mode? Why Execute non-GUI mode?
  • GUI consumes many Resources / Memory.
  • GUI is not recommending for heavy Load testing for a page.
  • Command line can be integrated with other systems also.

Related Article: JMeter with Selenium: A Comprehensive Guide to Performance Testing

Command line for the execution of the performance test is very handy to have. Let us begin the process of running the performance test using a command line.
 

Step-1: Add the test to check the HTTP request

Add the test to check the HTTP request

Step-2: Now, add the listener to Thread Group & execute the test

Add the listener to Thread Group & execute the test

Shows the Results of the response to the request for 10 users.

Now, We check how to Test the request using the command line. Remove the View Results in Table listener from HTTP request test & save the test. After Saving the test closes the Jmeter.

Create one blank .csv file & save it. Go to Command line, Go to the JMeter Bin folder. The command to execute the JMeter test you have to right below command in command line.

For mac: Sh Jmeter -n -t [Location of your test script] -l [Location of the result file]

If you are using any other OS you can simply remove ‘sh’ before the command.

Where,

-n: Is for use when we executing the file in non-GUI mode.

-t: Location of your JMeter test script.

-l: Is for the location of the result file where you want to log all the results.
Now, execute the Command:

sh jmeter -n -t /Users/mac35/Downloads/Nitroshare/apache-jmeter-3.0/bin/ViewresultComandline.jmx -l /Users/mac35/Downloads/NitroShare/apache-jmeter-3.0/bin/Demo.csv
Execute the Command

After executing the command it starts running the test & log the results into Demo.csv log file.

Run the test & log

On the basis of the observance it has been seen that, it logs all 10 users’ details as we check it with the use of Jmeter. We can use multiple users to check the load-timings & can request for more details. And we hope, this blog helps you to expand your core-JMeter-knowledge. Get in touch with our experts now!

For Web Development Services,

A command-line interface (CLI) processes commands to a computer program in the form of lines of text. The program which handles the interface is called a command-line interpreter or command-line processor.

Operating systems implement a command-line interface in a shell for interactive access to operating system functions or services.

We are going to execute the JMeter Tests in Non-GUI mode. Before that, we need to understand why we need to Execute the Test In Non-GUI mode.

Normally when we execute the Request in the Non-GUI Mode, it will send some requests to the server and get the response, and again it will take some time to generate the reports and view in the results to the user. so it will do some kind of process in the UI Level.

So we can not get the Actual result when we send the request and getting a response through UI. To avoid that situation we run JMeter Test in command prompt.

  • Basically GUI consumes more Memory/Resources.
  • And, GUI not recommended for heavy load testing because we will not get accurate results.
  • When we run the JMeter through the command line it can also be integrated with other systems-Jenkins and other continuo s integration tools.

The following example demonstrates how to run the JMeter in the Command-Line.

  • Open the JMeter in your system and then add Thread Group and then Three HTTP Request to the Thread Group.
  • And enter the Number of Threads as 5 and the Ramp-up period as 2 and then, the Loop count as 3.
    thread-group-number-and-ramp-up-number-loop-count-jmeter

  • Rename the HTTP Requests as HTTP Request1, HTTP Request2 and HTTP Request3.
    http-request-one-two-three-jmeter

  • In the HTTP Request1 add blazedemo link in the server and enter the path as /Register
    http-request-with-blazedemo-jmeter

  • Enter the login details in the Second request as below.
    seond-request-with-login-details-jmeter

  • Enter the root page details in the third request as below.
    root-page-details-in-http-request-jmeter

  • Next, add View Result Tree Listener into the Thread Group to see the report.
    add-view-result-tree-jmeterr

  • Enter the Result.csv file path in the view result tree as shown below.
  • Before running the test plan through the command line make sure that the CSV file is not available at the file location. So I am deleting the result.csv file from the MyPlans folder.
  • We are going to execute the command which not only going to create the CSV file, by using the details of the CSV file we also going to create an HTML report.
  • We can create an HTML report in two approaches:
    • To Create an HTML report at the end of the Test : which means, at the time of running the HTTP request we can create the HTML file.
      The Command to create CSV file and HTML report at once is as follow
      jmeter -n -t "D:Jmeter_Projectapache-jmeter-5.2.1inMyPlanscommandline.jmx" -l "D:Jmeter_Projectapache-jmeter-5.2.1inMyPlans
      esult.csv" -e -o "D:Jmeter_Projectapache-jmeter-5.2.1inMyPlanshtmlReports"​
    • Creating an HTML report with standalone CSV file : In this case, we have a CSV file, by using the details of this CSV file we can create the HTML report.
      The Command to create CSV file and HTML report is as follow
      jmeter -g "D:Jmeter_Projectapache-jmeter-5.2.1inMyPlans
      esult.csv" -o ""D:Jmeter_Projectapache-jmeter-5.2.1inMyPlanshtmlReports"
  • Open the Command prompt in the Bin folder of JMeter and then execute the first command as shown below.
    command-to-create-csv-file-and-html-report-jmteer

    html-report-dashboard-and-customerpgraphs-jmeter

  • After executing the command in the command prompt, if you open your file location you will find both Result.csv file and then HTML Report.
    created-htmlreport-and-csv-file-jmeter

  • Now I am going to delete the HTML Report and I have only Result.csv file.
    deleted-html-report-jmeter

  • Click on the HTML Report you fille below files inside the folder.
    files-under-html-repport-jmeter

  • Click on the Index file you will see the Dashboard, Customer Graphs, and Charts.
    deleted-html-report-jmeter

  • By using the Result.csv file details I am going to create an HTML report, but this time the Command will be changing a little bit as below.
  • In the folder, you can see that the HTML report has been created.
    html-reports-craeted-jmeter

Recommended Readings
  • Distributed Mode in JMeter
  • Distributed Testing in JMeter
  • Beanshell Sampler in JMeter
  • PreProcessor & PostProcessor in JMeter
  • Regular Expression Extractor in JMeter
  • Timers in JMeter
  • Logical Controller of JMeter
  • Assertions in JMeter

0 results

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Драйвера для imac 2011 для windows 10
  • Minimal bash like line editing is supported for the first word tab решение windows 10
  • Send file from windows to ubuntu
  • Модем на шине high definition audio для windows xp для ноутбука acer
  • Windows 10 платная подписка