Use JMeter to execute N requests for an interface address or a page address, and here's how to create a test script (also known as a "test plan").
1. Running Jmeter.bat
Double-click the "Jmeter.bat" file and wait a moment for the Jmeter to be started, as shown in:
2. Set up thread groups
Under the node "test Plan", build 1 things called "thread groups", as shown in:
What is the role of this "thread group"?
Its role is to control the number of threads.
Even after you click Thread groups, the setup is complete. The effect is as follows:
3. Establishing the HTTP request default value
Under the node "thread Group", create 1 things called "HTTP request Defaults", as shown in:
After you click HTTP request defaults, even if Setup is complete. The effect is as follows:
4. Fill in the "HTTP request Defaults" form ("watercress-movie" for example)
"Server name or IP" write: movie.douban.com
Other places are written as shown, and of course the project needs to be met, but most of the interface tests are like this.
After this is written, you can reduce the workload for the next job.
5. Create a single request
Under the node "thread Group", create 1 things called "HTTP requests", as shown in:
I want to create 2 "HTTP requests" to reflect the "HTTP request defaults" effect.
Even after you click HTTP request, the setup is complete. The effect is as follows:
As I said earlier, "I want to create 2 ' HTTP requests ' to reflect the ' HTTP request defaults ' effect." "So I set up 2 ' HTTP requests '.
6. Fill in the "HTTP Request" form ("watercress-movie" for example)
1th HTTP request for a form
"Path" write:/subject/1835843/
Somewhere else, keep the default value.
2nd HTTP request for a form
"Path" write:/subject_search?search_text=night+at+the+museum
Somewhere else, keep the default value.
Why don't I need to write other field values for my form?
Because the HTTP request defaults have already been written.
Why write this all in advance of HTTP request defaults?
Because typically, the requirement is to perform performance testing on different pages of the same site. So in fact, some of the common domain values are the same, in order to reduce the workload is not necessary to write every time, but written in the "HTTP request default Value" of the 1 things in it.
Why is the path only half written?
Because the first half of "movie.douban.com" has already been written in the HTTP request defaults.
7. Build 1 Listeners
Under the node "test Plan", build 1 things called "View results Tree", as shown in:
Of course you can also create "graphical results," "Assert results," "aggregated reports," "View results with tables," and other forms of listeners. Each type of listener acts as a collection of performance test results, and only renders the results differently, depending on the specific business, or in conjunction with what the developer "wants to see".
When you click View Results tree, the setup is complete. The effect is as follows:
8. Keep only 1 HTTP requests
For every 1 performance test scripts, only 1 or n requests are executed for 1 interfaces (or 1 pages).
Therefore, you need to keep only the 1 "HTTP requests" for the interface (or page) to be tested before the test script executes.
So, we can see that the current test plan contains 2 "HTTP requests".
So, let's just "disable" 1 of them. The effect is as follows:
The effect of 1 of these "HTTP requests" being "disabled". As shown in the following:
9. Execute 1 Test scripts
Switch to Thread Group
You can see that the default number of threads is "1", and the number of cycles is "1"
Ramp-up Period (in seconds) means "want to start all threads in a few seconds"
Action to execute script: ctrl+r
The "Empty test results" operation can be performed before executing the script: ctrl+e
10. View Test Results
Switch to "View results tree"
Click on these 1 "HTTP requests" in the list on the right
On the right, you can view the data in the sampler results, request, Response Data tab, respectively
11. Perform another 1 HTTP requests
Method with the contents of section 8th.
The specific is:
Step [1]-Enable another 1 HTTP requests
Step [2]-disable other HTTP requests at the same time
12.20 Threads + Loop 2-time method
Switch to Thread Group
Set the number of threads to write "20" and the number of cycles to write "2"
Due to the small number of threads, there is no need to consider how to set ramp-up Period (in seconds).
13.20 Threads + scripts run for 60 seconds
Switch to Thread Group
Set the number of threads to write "20"
Cycle times Write "Forever"
Tick "Scheduler"-> Duration (seconds) write "60"
Due to the small number of threads, there is no need to consider how to set ramp-up Period (in seconds).
-end
jmeter-script for a complete interface test