Apache JMeter is a Java-based open-source load testing tool that offers intuitive test design through a GUI and powerful distributed testing. It supports many protocols, including HTTP, FTP, JDBC, and JMS.
JMeter Practical Examples
Examples for Thread Groups, CSV datasets, HTML reports, and distributed testing.
View practical examples โApache JMeter is a Java-based open-source performance testing tool created by Stefano Mazzocchi in 1998. Because complex test scenarios can be assembled through the GUI without code, it is especially popular with QA engineers.
| Feature | Description |
|---|---|
| GUI-based | Design tests by drag and drop, without code |
| Multi-protocol | HTTP, HTTPS, FTP, JDBC, JMS, SOAP, REST |
| Distributed testing | Generate large-scale load with a Controller + Slave setup |
| Plugin ecosystem | Extensible through the JMeter Plugins Manager |
JMeter requires Java 8 or later.
# Check Java
java -version
# macOS (Homebrew)
brew install jmeter
# Manual install (any OS)
# Download the .tgz from https://jmeter.apache.org/download_jmeter.cgi
tar -xzf apache-jmeter-5.x.x.tgz
cd apache-jmeter-5.x.x/bin
./jmeter # launch the GUI (macOS/Linux)
jmeter.bat # launch the GUI (Windows)Create it via Test Plan โ Add โ Threads โ Thread Group.
Add it via Thread Group โ Add โ Sampler โ HTTP Request.
Server Name: httpbin.org
Port: 443
Protocol: HTTPS
Method: GET
Path: /getAdd it via HTTP Request โ Add โ Assertions โ Response Assertion.
Field to Test: Response Code
Pattern Matching Rules: Equals
Patterns to Test: 200A JSON Path Assertion can validate the value of a specific field in the response JSON. Use Add โ Assertions โ JSON Assertion.
Name: BASE_URL
Value: https://api.example.com
# Usage: ${BASE_URL}/usersusername,password
user1,pass1
user2,pass2
user3,pass3Load the CSV via Thread Group โ Add โ Config Element โ CSV Data Set Config and use its columns as variables.
Use Non-GUI mode for CI/CD and large tests. GUI mode consumes a lot of resources.
jmeter -n -t test-plan.jmx -l results.jtl -e -o report-dir| Option | Description |
|---|---|
-n | Non-GUI mode |
-t | .jmx test plan file |
-l | Results log file (.jtl) |
-e | Generate the HTML report after the test |
-o | Report output directory |
# Generate the report as part of the test run
jmeter -n -t test-plan.jmx -l results.jtl -e -o ./report
# Generate only the report from an existing .jtl file
jmeter -g results.jtl -o ./reportOpen ./report/index.html in a browser for a detailed analysis report including the response time distribution, throughput, and error rate.
For load beyond what one machine can generate, use a Controller + Agent (Slave) setup.
# jmeter.properties on the Controller
remote_hosts=192.168.1.101:1099,192.168.1.102:1099# Run on each Agent server
jmeter-server
# Run the distributed test from the Controller
jmeter -n -t test-plan.jmx -r -l results.jtlname: JMeter Load Test
on: [push]
jobs:
load-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { java-version: '17' }
- name: Install JMeter
run: |
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.6.3.tgz
tar -xzf apache-jmeter-5.6.3.tgz
echo "$PWD/apache-jmeter-5.6.3/bin" >> $GITHUB_PATH
- run: jmeter -n -t tests/load-test.jmx -l results.jtl -e -o report
- uses: actions/upload-artifact@v4
with: { name: jmeter-report, path: report/ }