Before using jmeter for a single interface test, let's take a look at the process of a user request , as follows:
1) The user initiates a request through the browser ;
2) The user receives the response data returned by the server .
As above, it is a WEB request/response model
If jmeter wants to test the WEB interface, then it has to simulate this request-response model, and it has to have the following elements:
1) User (or call it thread);
2) Request to send;
3) Response received.
Next, we use jmeter to test the interface based on the above elements
1. Test plan
Open the jmeter test tool, we see a default generated test plan (test plan), all our operations are based on the test plan .
You can change the name of this test plan, or you can save the new test plan locally so that you can open it later.
2. Add a group
We need to simulate the user, the user may be one or more.
Right-click Test Plan -> Add -> Thread (User) -> Group
We see an additional group under the test plan
The thread properties section in the right panel of the group :
1) The first item means: how many users to simulate
2) The second item indicates: how much time did these users generate
3) The third item means: the number of cycles
3. Request
After we have the user, we need to simulate the request
Right click on the group -> Add -> Template -> Add Http Request
We can add relevant content in the right panel, such as:
1) Agreement
2) IP/Domain Name
3) Port
4) Request parameters
4. Response
According to the request, jmeter needs to receive the response data
Right click on request -> Add -> Listener -> Result tree
5. Operation
We have simulated a request-response structure in the above four steps, now you only need to
1) Check the request
2) Click the green run button just above to send the request ;
3) View the response data in the result tree