In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Overview
In the process of interface automation, we often encounter groups of parameters that need to be traversed. In jmeter, the foreach controller can implement traversal parameters, but there can only be one input parameter. Once encountered with an array, the foreach controller said there was nothing I could do.
In order to solve this problem, I will teach you a way to implement array traversal today.
Involved element
Json expression + Loop Controller + counter + matchNr function + beanshell script
Case analysis
First of all, let's look at an example. In the following figure, we need to write the parameters in the three sets of return values to the local file. For example, province: population
First of all, we need to extract these three sets of parameters through JSON Extractor
Looking at debug, we can see that these three sets of data all appear in pairs. {name_1,population_1}; {name_2,population_2}; {name_3,population_3}. The total is calculated by the matchNr function
Add a loop counter with the number of cycles as matchNr. It means to count several sets of data, and the script traverses it several times.
Add a counter under the loop controller to specify the number of rows to read. The maximum value is also the value calculated by matchNr
Add a beanshell script under the controller to write the read parameter traversal to the local file. Through the function nesting of the counter, traverse each set of data and write to the local file in a loop.
FileWriter fstream = new FileWriter ("D:\\ parameter table .txt", true); BufferedWriter out = new BufferedWriter (fstream); out.write (vars.get ("name_$ {num}") + "population" + ":" + vars.get ("population_$ {num}") + "ten thousand"); out.write (System.getProperty ("line.separator")); out.close (); fstream.close ()
Observe the response result
Written local file
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.