Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Five methods of jmeter correlation

Shulou Source: shulou.com Published: 2022-06-03 03:06:59 11月17日 Update

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]

Tags: Association test search mode top search results results references methods usage interfaces servers samplers services dynamic variables addresses dictionaries characters strings Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS MariaDB Redmi Shulou Technology