JMeter BeanShell Instance-----Assertion comparison between two variables

Source: Internet
Author: User

In JMeter, the assertion is not able to compare two variables to judge, can only use the bean shell assertion to do, always someone to ask how to write it. Let's write a simple example here.

Demand:

Gets the number of devices that a user corresponds to and compares the results of a database query

Bean Shell Assertion Solution:

To get a user's corresponding number of devices interface this normal HTTP interface, here is not listed

Queries with the Oracle database, such as

The JDBC Connection configuration is first established, the JDBC query is made, and then the regular extractor is used.

Then build the bean shell assertion as follows

Here is the introduction. ${STREAMID_MATCHNR} is a statistic of the number of JMeter

if (! " ${STREAMID_MATCHNR} ". Equals (" ${res_1} "))

Indicates that ${STREAMID_MATCHNR} is not equal to ${res_1} and runs the following code.

A few lines of bean shell to solve the problem quickly

JMeter BeanShell Instance-----Assertion comparison between two variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.