In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the ways of jmeter to achieve interface association". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the ways of jmeter to achieve interface association"?
I. Preface
In the process of interface testing or interface interview, we will find that many interfaces need to rely on the previous interface, which requires us to dynamically extract data from the previous interface return, which is what we usually call association.
Second, use regular expression extractor to realize interface association.
The regular expression extractor, known by name, is to match what we need to extract by using the method of regular expression.
Principle: the return value of the intermediate change is extracted through the invariant boundary between the left and right sides.
As shown above: access_token needs to be extracted.
{"access_token": "31_qz2HtPalsk5Ey1ToWJaZ6Kaojf8y-BhxTHEmuO111m8_Gc_77HRvMuG4ltbd9gHskqi0XAq8phQys9K8awso4iq-VSr0bArrd-zC-nY0Ltudp-HcPZV7y291YjLYoeJBHW2zhB7-lWYzeTsqFKOhAHANSW", "expires_in": 7200}
1. Right-click on the request "1. Get access_token" to add a post processor-- > regular expression extractor
Reference name: the name of the parameter to be referenced in the next request. If you fill in access_token, you can reference it with ${access_token}.
Regular expression: the part enclosed by () is to be extracted. . For any character, + for one or more times, and * for any number of times.
Template: referenced with $$, if there are multiple regular expressions in the regular expression, it can be $2 $, $3 $, and so on, indicating the number of values parsed to access_token. There is only one in this office, all of which use $1 $.
Matching numbers: 0 represents random,-1 represents all, and the rest of the positive integers represent the number of matches that will be extracted from the checked content.
two。 Use ${access_token} references in later interfaces
3. Use the debug sampler to check whether the extraction is successful
Add Debug Sampler-- > run Test-- > View results by viewing Debug Sampler in the result Tree
If you think this article is helpful to you, if you have any questions about this article, if you are interested in software testing, interface testing, automated testing, interview experience exchange, welcome to join the software testing technology group: 695458161, the free materials distributed in the group are the essence of the author's testing career for more than ten years. There are also fellow gods to exchange technology together.
Third, use json extractor to realize interface association.
Usage: API association. Currently, the data returned by an API is in json format, and you need to extract data from the returned json data.
You can copy the returned value to www.bejson.com-- > json menu-> json View-> json data, and then click to try to view it, as shown below:
Steps for using json extractor
1. Right-click on the request "1. Get access_token" to add a post processor-- > JSON extractor
Name of created varialies: the name of the parameter to be referenced in the next request. If you enter access_token, you can reference it with ${access_token}.
JSON Path expressions: fill in jsonpath, format: $. Node name root node uses "." Express
Match Numbers:0 stands for random,-1 for all, and the rest of the positive integers represent the number of matches that will be extracted from the checked content.
Default Values: the default value when cannot be found, which is generally set to NOT FOUND
Compute concatenation var (suffix_ALL): whether to count all the values that are about to be matched, named "variable name _ ALL"
two。 Replace the variable with ${variable name}
3. Use the debug sampler to check if the
Fourth, extension: return the extraction of complex json data
Figure: {"tag": {"id": 193, "name": "newdream20200324"}}
The JSON extractor is configured as follows: $.tag.name
Thank you for your reading. the above is the content of "what are the ways in which jmeter implements interface association". After the study of this article, I believe you have a deeper understanding of the way jmeter implements interface association, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.