In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the dependence of JMeter interface". In daily operation, I believe that many people have doubts about what the JMeter interface depends on. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what is the dependence of JMeter interface?" Next, please follow the editor to study!
There are two main situations:
The same thread group, different requests, need to be associated.
Request B fails (because of the need for association), then from the request before request B, such as request A, and from the response data
Find the content that needs to be associated, such as token, sessionid, etc., after the association, submit the B request again as the request data of request B.
Right-click on request A-add-post processor-boundary extractor
Replace the actual token in the request B parameter with the associated token variable
Run again, the association is successful, and request B is successful.
two。 There are dependencies between different thread groups and different requests.
The test plan is structured as follows:
As can be seen from the above figure, there is a login interface in thread group 1 and a shopping cart interface in thread group 2.
Cookie is required to join the shopping cart request. If you can't get it, it means you haven't logged in, so you can't join the shopping cart.
Generally speaking, adding HTTP Cookie Manager is fine. As you can see from the figure above, it has been added, juxtaposed with the two thread groups.
However, after running, add the shopping cart interface first, and then execute the login interface, which results in that the shopping cart has not been logged in yet.
Why aren't threads 1 and 2 executed sequentially?
This is because if there are multiple thread groups under the test plan, they are not executed sequentially, but at the same time, not necessarily who comes first.
So, how do you get them to do it in strict order?
Under the test plan, check "run each thread group independently" to allow the two to be executed sequentially.
After the check box, run it again and execute it in strict order.
However, when you join the shopping cart request, you are still prompted to log in. Why?
This is because thread group 1 login request cookie, which is a thread variable, is a local variable, and the scope is the thread group in which it is located.
So, how do you make it work on thread groups other than it?
Idea: take the value of this thread variable using vars.get (), and then use props.put () to put it in the global variable.
It should be noted that after placement, you need to restart jmeter for the property to take effect (thread variables do not need to be restarted).
After restarting, another thread group can access this global variable.
Do the following:
In thread group 1, for the login request, add the post processor-BeanShell PostProcessor, as follows:
As you can see in the figure above, the HTTP Cookie Manager has been repositioned to move it under thread 1, but there is no need to configure cookie
Under thread group 2, a HTTP Cookie Manager is also added to get the value in the attribute (global variable) cookie22.
Take out the value of the attribute (that is, the global variable) cookie22 using the function _ _ P or _ _ property.
Note: here, you cannot use the format ${} to get a value, because this is an attribute, not a variable, so you can only use a function here.
Then, in the HTTP Cookie Manager, add the cookie (JSESSIONID) and paste the letter number string
Why add a HTTP Cookie Manager here and add a cookie manually?
Because if you don't add it manually, the cookie won't come through.
Run and join the shopping cart successfully.
Summary: the above is the solution to the problem of cookie transfer between different thread groups.
By the same token, this method can also be used if there is an interface association between different thread groups.
Because in the above example, the login and cartby requests are in two thread groups, you can set to run the login only once, but make multiple cartby requests.
At this point, the study of "what is the dependence of the JMeter interface" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.