Software Introduction
JMeter is a Java-developed, open-source, free, test tool used primarily for functional testing and performance testing (stress test/load testing), and for testing Restful APIs using JMeter.
How to learn JMeter well:
If you use JMeter to perform functional testing on the Web, or performance testing. You must be proficient in the HTTP protocol to learn jmeter well. Otherwise it's hard to understand the concept of jmeter.
JMeter Run:
After decompression, run "Bin/jmeter.bat"
Jmeter is supported in Chinese, after starting Jmeter, click Options, Choose Language to select the language
Examples of actual tests:
Goal: Get weather data for the city:
First step: Send request to get city code
Http://toy1.weather.com.cn/search?cityname= Shanghai
Get the city code of Shanghai from the response of this request. Like what:
The area code for Shanghai is 101020100.
The area code for Shanghai Zoo is: 10102010016A
Step two: Send request to: http://www.weather.com.cn/weather2d/101020100.html can get weather data for the city
First step: Create a new thread Group
You must create a new thread group, all tasks for jmeter must be handled by the thread, and all tasks must be created below the thread group.
Step Two: Create a new HTTP Request
For example, I want to send an HTTP request for a GET method: Http://toy1.weather.com.cn/search?cityname= Shanghai
You can fill in this
The third step is to add the HTTP Head Manager
Select the new HTTP request that you created in the previous step. Right-click to create a new HTTP Header manager. Add a header
Fourth step: Add View Results Tree
View Results Tree is used to see the results of the run
Fifth step: Run the test to see the results
to here. We've managed to get it running.
Sixth step: Add assertion and Assert Results
Select HTTP Request, right-add-> assertions, Response assertion. Add Patterns to test
Then add a assetion Results to see the results of the assertion execution.
Check the thread Group right-click Add-Listener-assertion Results.
After running, if the HTTP response does not contain the expected string. Then test will fail.
7th step: Using user-defined variables
We can also define variables in JMeter. For example, I define a variable called City. Use it when using ${city}
Add a User Defined Variables. Check the thread Group: Right-click Add, Config Element, User Defined Variables.
We add a variable: City
Then use this variable in the HTTP request
Eighth Step: Association
The so-called Association is the second requst, using the data from the first request
We need to create a new regular expression in the first HTTP requst, extract the value of the response into the variable and provide it to other HTTP request
Select the first HTTP Request, right-click Add, Post processors, Regular expresstion Extractor
Now create a second HTTP Request, send to: http://www.weather.com.cn/weather2d/${citycode}.html
The data in ${citycode} is taken from the regular Expression Extractor
Here, the script is all written, run, and look at the final result.
Closed software Tags: load test stress test
Apache JMeter Open Source stress test/Load Test Tool 2.12 Official latest version