Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Five methods of jmeter correlation

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Original address: www.cnblogs.com/UncleYong/p/10939647.html

A few days ago, I saw the statistics of the usage rate of performance test tools in the last 10 years in Q group. In 2018, jmeter+loadrunner accounted for 93% of the usage rate, indicating that these two are mainstream. Among them, the usage rate of jmeter has increased year by year, and now it has exceeded loadrunner, accounting for 51%.

In addition to performance, jmeter can also do automated testing, such as jmeter + ant + jenkins automated testing framework (reference: https://www.cnblogs.com/UncleYong/p/10739519.html), jmeter can also do interface function testing, so jmeter should be a necessary skill for every test engineer.

Here, we focus on jmeter correlation, what is correlation? Store the dynamically changing value provided by the server in a variable. When the variable needs to be used, the value is automatically obtained from the information in the server response and replaced in the process of later use. (It may also be a dynamically generated value on the front-end page)

There are many ways to associate jmeter, here are 5 ways, there is always one that you like. If you want to know about the association of loadrunner, you can refer to LoadRunner [Part 5] Association: www.cnblogs.com/UncleYong/p/10702702.html

back to top

script is ready

Here, we use the dummy sampler to simulate the return of the server, obtain the value of the name by association, and then Baidu searches for the value of the name, which simply simulates the dependency relationship between the requests.

Add dummy sampler

Set Back Content

The keyword searched for is the name value returned from the previous request

Print the value of the obtained name

Commissioning sampler

back to top

Method 1: Regular Expression Extractor

Regular.*?, Reference: www.cnblogs.com/UncleYong/p/10779268.html

Associated with the acquired value

Baidu search results

back to top

Method 2: jp@gc - JSON Path Extractor

$indicates the return value of the interface. If the value of the dictionary key is taken, the dot is used. If it is a certain value of the list, the index is used.

Associated with the acquired value

Baidu search results (omitted)

back to top

Method 3: Json Extractor

Similar to method 2,$represents the return value of the interface. If the value of the dictionary key is taken, the dot sign is used. If it is a certain value of the list, the index is used.

Associated with the acquired value

Baidu search results (omitted)

back to top

Method 4: Boundary extractor

This is very similar to the association in loadrunner, which is valued by left and right boundaries. Refer to www.cnblogs.com/UncleYong/p/10702702.html

Associated with the acquired value

Baidu search results (omitted)

back to top

Method 5: beanshell postprocessor

Write a beanshell script that parses the json string.

fastjson, jar package download address: mvnrepository.com/artifact/com.alibaba/fastjson

After downloading, put the jar package under D:\apache-jmeter-5.1.1\lib\ext and restart jmeter.

Then restart jmeter.

fastjson Parse json string

Baidu search results (omitted)

So far, all five ways have accurately obtained the values that need to be associated.

To be a warm-hearted test technology sharer, please pay attention to Weixin Official Accounts [qzcsbj], join the test dry goods sharing Q group [652122175] or add the author Q number [168632201] to consult the test questions. For more dry goods, please pay attention to [https://www.cnblogs.com/UncleYong/p/10530261.html]

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report