jmeter test to get the result of the last request as the parameter of this request

        Jmeter is a stress testing tool developed based on java. Of course, it can also be used as an interface testing tool. It is especially convenient for app testing that requests an Http connection interface. It can test the request results and concurrently analyze the pressure load. There are various data as analysis conditions to For testers and developers to use and optimize projects.

        This article focuses on the pipeline test of the interface, taking logging in and then obtaining data as an example.

        The download, installation and usage of jmeter will not be described too much, there are a lot of Baidu methods.

        (1): First, create a thread group in TestPlan. Then add an HTTP Request request to the thread group, fill in the login request path and Method, and then fill in the parameters.

        (2): Add two 'regular expression extractors' for the login request HTTP Request to view the result tree. Fill in the reference name, regular expression, template and matching number in the regular expression (specific analysis later).


        (3): Add an HTTP Request for obtaining the user device to the thread group again:


        (4): Add 'HTTP Information Header Manager' and 'View Result Tree' for the HTTP Request request of the user device, and then add the corresponding parameters in the information header (the one that was put into the regular expression extractor from the last request) parameters), in the format ${***}:


        (5): Click the Start (green triangle) button to view the results:



It is seen that the uid and token in the http header manager have values ​​and the data is successfully obtained. So far, the process of obtaining the result of the last request as the parameter of this request in the jmeter test is basically over.

    Summary: Why is uid and token obtained in different ways, because token is of string type, and uid is of int type, it is a little more troublesome to obtain int type .

The way to get uid is "uid":(.*), and the way to get "rest":0 token is "token":"(.*?)"    

The reason why there is one more way to get the uid, "rest": 0, is to allow the regular expression to intercept the place where "rest": 0, and if you don't write, "rest": 0, the "uid" will be directly ": All the following data are obtained.

The following figure shows the returned data from the first login request, which contains uid and token as parameters for the second request.


Guess you like

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