RelationDigest

Wednesday, 5 July 2023

[New post] How to run JMeter tests from the command line

Site logo image vibssingh posted: "  HOME In this tutorial, we will explain how to run tests in JMeter in non-GUI mode (Command Line mode). Why execute tests in non-GUI mode? The JMeterGUI's inability to handle huge loads and excessive resource consumption risks overloadin" QA Automation Expert

How to run JMeter tests from the command line

vibssingh

Jul 5

 
HOME

In this tutorial, we will explain how to run tests in JMeter in non-GUI mode (Command Line mode).

Why execute tests in non-GUI mode?

The JMeterGUI's inability to handle huge loads and excessive resource consumption risks overloading the server, which would give you inaccurate test results information. Additionally, the less load you can generate throughout your tests, the more resource-intensive the server is.

Sample Request

 {     "name": "Test",     "job": "JMeter" } 

Sample Response

 {   "name":"Test",   "job":"JMeter",   "id":"955",   "createdAt":"2023-07-03T15:46:18.038Z" } 

Create a Test Plan in JMeter by following the below-mentioned steps

Step 1 -  Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               To add Thread Group: Right-click on the "Test Plan" and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: We will take an example of row no 5

Number of Threads: 5 - Number of users connects to the target website
Loop Count: 5  - Number of times to execute testing
Ramp-Up Period: 5 - It tells JMeter how long to delay before starting the next user. For example, if we have 5 users and a 5 -second Ramp-Up period, then the delay between starting users would be 1 second (5 seconds /5 users).

Step 2 -  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send

2.1 Add HTTP Request Sampler
To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

The below-mentioned are the values used in HTTP Request to perform the test

  • Name - HTTP POST Request Demo
  • Server Name or IP - reqres.in
  • Port - Blank
  • Method - POST
  • Path - /api/users

2.2 Add HTTP Head Manager

The Header Manager lets you add or override HTTP request headers like can add Accept-Encoding, Accept, Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager

The below-mentioned are the values used in Http Request to perform the test
Content-type = application/json
accept - application/json

Step 3 - Adding Listeners to Test Plan

Listeners - They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file
We are adding the View Result Tree listener

View Result Tree - View Result Tree shows the results of the user request in basic HTML format
To add: Right-click on Test Plan, Add -> Listener -> View Result Tree

Aggregate Report

It is almost the same as Summary Report except Aggregate Report gives a few more parameters like, "Median", "90% Line", "95% Line" and "99% Line".

 To add: Right Click on Thread Group > Add > Listener > Aggregate Report

Step 4 - Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved in .jmx format.

The below image shows that the test is saved in Documents with the name POST_Load.jmx.

Step 5  - Run the Test Plan from Command Line

Open the command prompt and go into JMeter's bin folder.

 cd C:\Users\Vibha\Documents\apache-jmeter-5.6\apache-jmeter-5.6\bin 

Step 6 - View the Execution Status

Enter the following command:

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

This is the command used in the script:

 jmeter -n -t C:\Users\Vibha\Documents\apache-jmeter-5.6\apache-jmeter-5.6\POST_Load.jmx -l C:\Users\Vibha\Documents\JMeterResult\result.jtl 

Below is the detail about the commands used in the execution.

-n: This specifies JMeter is to run in cli mode

-t: [name of JMX file that contains the Test Plan]

-l: [name of JTL file to log sample results to]

The test execution is displayed in the command line as shown below:

The result.jtl is saved as mentioned in the above command in the JMeterResult folder present in Documents:

Let us open the result.jtl file.

It is very difficult to understand the result in this format. So, open JMeter in GUI mode.

Mention the location of the file in the Filename of the "View Results Tree" listener and hit enter. We can see the result now.

Click on Response data and Response Header to view other information about Response.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Comment
Like
Tip icon image You can also reply to this email to leave a comment.

Unsubscribe to no longer receive posts from QA Automation Expert.
Change your email settings at manage subscriptions.

Trouble clicking? Copy and paste this URL into your browser:
http://qaautomation.expert/2023/07/05/how-to-run-jmeter-tests-from-the-command-line/

WordPress.com and Jetpack Logos

Get the Jetpack app to use Reader anywhere, anytime

Follow your favorite sites, save posts to read later, and get real-time notifications for likes and comments.

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com on Twitter WordPress.com on Facebook WordPress.com on Instagram WordPress.com on YouTube
WordPress.com Logo and Wordmark title=

Automattic, Inc. - 60 29th St. #343, San Francisco, CA 94110  

at July 05, 2023
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Trust is a rhythm, not a moment.

It's built over time, not all at once.  ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌...

  • [New post] Wiggle Kingdom: April Earnings on Spring Savings!
    Betsi...
  • [New post] Balancing the ‘E’ and ‘S’ in Environment, Social and Governance (ESG) crucial to sustaining liquidity and resilience in the African loan market (By Miranda Abraham)
    APO p...
  • Something plus something else
    Read on bl...

Search This Blog

  • Home

About Me

RelationDigest
View my complete profile

Report Abuse

Blog Archive

  • August 2025 (37)
  • July 2025 (59)
  • June 2025 (53)
  • May 2025 (47)
  • April 2025 (42)
  • March 2025 (30)
  • February 2025 (27)
  • January 2025 (30)
  • December 2024 (37)
  • November 2024 (31)
  • October 2024 (28)
  • September 2024 (28)
  • August 2024 (2729)
  • July 2024 (3249)
  • June 2024 (3152)
  • May 2024 (3259)
  • April 2024 (3151)
  • March 2024 (3258)
  • February 2024 (3046)
  • January 2024 (3258)
  • December 2023 (3270)
  • November 2023 (3183)
  • October 2023 (3243)
  • September 2023 (3151)
  • August 2023 (3241)
  • July 2023 (3237)
  • June 2023 (3135)
  • May 2023 (3212)
  • April 2023 (3093)
  • March 2023 (3187)
  • February 2023 (2865)
  • January 2023 (3209)
  • December 2022 (3229)
  • November 2022 (3079)
  • October 2022 (3086)
  • September 2022 (2791)
  • August 2022 (2964)
  • July 2022 (3157)
  • June 2022 (2925)
  • May 2022 (2893)
  • April 2022 (3049)
  • March 2022 (2919)
  • February 2022 (2104)
  • January 2022 (2284)
  • December 2021 (2481)
  • November 2021 (3146)
  • October 2021 (1048)
Powered by Blogger.