In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains how to compare the API return value with the database query value in Jmeter. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to compare the API return value with the database query value in Jmeter.
I believe that many junior and intermediate test students may have encountered, then how to do assertion verification is efficient and accurate? Today, around the test sharing of jmeter interface, the author uses BeanShell assertion to compare the API return value with the database query value.
First, configure Jmeter to connect to the Mysql database
Go to mysql's official website to download mysql-connector-java-bin.jar. I downloaded version 5.1.46 here:
Link: https://pan.baidu.com/s/1fW76mABU0mh5NkXJEC-zTQ password: 6miq
1.1 configure JDBC Connection Configuration in Jmeter
1.2JDBC Request request:
Load the downloaded jdbc driver into the Jmeter tool, which connects mysql to Jmeter. Select the test plan- to enter the page and click the browse button, as shown in the figure
1.4 Click the green arrow to run the script and view the result tree to get our SQL value
At this point, the jmeter link database has been completed
Second, use BeanShell assertion to verify
The field value in the 2.1API return value can be extracted by the regular expression extractor
2.2 name the value queried in the database in the form of a variable (assuming a), and next time the value can be obtained through $aq.1. How do you compare it? Attach the code:
If (! "${identifyCode}" .equals ("${validate_code_1}")) {
Failure = true
FailureMessage = "error,check error"
} else {
FailureMessage = "ok,check current"
}
Code description: identifyCode is a variable referenced by the value extracted by my regular expression
Validate_code_1 is a variable referenced by the value I queried through the SQL statement
The current case is considered to be pass only if the value returned by API matches the value found by the database query, otherwise it is Fail.
At this point, I believe you have a deeper understanding of "how to compare the API return value with the database query value in Jmeter". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.