Jmeter4.0---- write test scripts (5)

 

1. Description

Taking HTTP request as an example, share the basic steps

 

2. Step Instructions

Step 1: Open jmeter, change the test plan name to Test batchSignForDir (modify the plan name, try to make it meaningful and easy to understand)

 

Step 2: Right-click on the test plan (Test batchSignForDir) to create a "thread group" and change the thread group name to batchSignForDir

 Test batchSignForDir (right mouse button)---->Add---->Threads(Users)---->Thread Group

(1) The number of threads : the number of users, a virtual user occupies a process or thread, how many users are required to be concurrent, and how many virtual users are set here is how many threads are set.

(2) Ramp-Up Period (in seconds) preparation time : how long it takes for the set number of virtual users to start all up. If the number of threads is 100 and the preparation time is 10, then it takes 10 seconds to start 100 threads, that is, 10 threads are started every second.

(3) Number of loops : The number of times each thread sends a request. If the number of threads is 20 and the number of loops is 100, then each thread sends 100 requests. The total number of requests is 20*100=2000. If "Forever" is checked, then all threads will always send requests, and once you choose to stop running the script.

 

 Step 3 : Add HTTP Header Manager

 Test batchSignForDir (right mouse button)---->Add---->Configuration Element---->HTTP Header Manager

 HTTP Header Manager: It is used to customize the content of the request header of the HTTP request sent by Sampler.

Content-Type can be understood as the parameter name and type. Just enter the corresponding parameter type below the value. Here I need to transmit the json type when testing, so I fill in application/json

 

Step 4 : Create HTTP Request

batchSignForDir (right mouse button)---->Add---->Sampler---->HTTP Request

Test batchSignForDir (right mouse button)---->Add---->Listener---->View result tree

 Fill in the user protocol corresponding to the interface under test in the HTTP request, use the server address, port, method, here I use POST, then fill in the path, select Body Data, and fill in the parameters of the request (these parameters can be Obtained from the interface file provided by the development or captured by yourself)

(1) Protocol : protocol when sending http requests to the target server, http/https, case insensitive, default http

(2) Server name or IP : The name or IP address of the target server sent by the http request, such as http://www.baidu.com

(3) Port number : the port number of the target server, the default value is 80, which can be left blank

(4) Method : Method of sending http request (link: http://www.cnblogs.com/imyalost/p/5630940.html)

(5) Path : The URL path of the target (excluding the server address and port)

(6) Content encoding : The encoding method of the content (Content-Type=application/json;charset=utf-8)

(7) Automatic redirection : If this option is selected, the HTTP request sent is responded with 301/302, and jmeter will redirect to the new interface

(8) Follow redirection : The default option of the Http Request sampler, but when the response code is 3XX (for example, 301 is redirection), it will automatically jump to the target address.

(9) Use keep Alive : Use Keep-Alive for HTTP communication between jmeter and the target server (selected by default)

(10) Use multipart/from-data for HTTP POST : When sending HTTP POST requests, use

(11) Parameters, Body Data and Files Upload  : Which one to use depends mainly on what type of Content-Type is set in the HTTP header manager

 

Step 5 : Run jmeter and view the results

 

 

A simple small case is done here. If you run the error, or the results are inconsistent with the expected results, please check whether some parameters you entered are correct.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324855249&siteId=291194637