Using external Java files in JMeter

Source: Internet
Author: User

feel that using external Java files in the JMeter is convenient, the same syntax, and can be directly referenced, so personally think this function is quite important, especially in the process of using jmeter, may need to combine certain business scenarios to judge, etc. The use of JMeter with the function may not be able to meet their own test requirements, at this time, the use of their own functions can be very good to meet their needs.

First, you can directly write Java files or class files directly, there has been a blog post, http://blog.csdn.net/quiet_girl/article/details/ 50577324, there are three ways to use Java files, the latter two are the introduction of external Java files, the first is directly in the JMeter to write functions.

Second, in addition to the above several methods, there is a Java file into a jar file, in the JMeter directly call, I think this method should be the most convenient, the jar package in a directory, configure the path, and then can be called as in Eclipse, The following is a detailed explanation of how to use the external jar file in JMeter.

1. First generate the Java file Jar file, the method of generation in the previous post has a detailed interpretation, blog url:http://blog.csdn.net/quiet_girl/article/details/50739963

2. Create a new file in the JMeter directory, name the folder yourself, here is dependencies, and then put the generated jar package in this directory, where the jar package file name is com.test.Math.SqrtCalc.jar (the jar package generated in the previous blog post, function is to have a sqrt function, to find the square value, relatively simple, detailed content http://blog.csdn.net/quiet_girl/article/details/50739963), such as:

3. Then open the Jmeter.properties file under the Bin directory folder, mind using Ctrl+f to find plugin_dependency_paths this property, and then set it to plugin_dependency_paths=../dependencies; , for example:

4. Start calling this function in JMeter, first open jmeter, create a new test plan, create a new thread group in the test plan, and then create a new BeanShell Sampler under the thread group, just BeanShell Sampler Write the code in the script box below, without additional configuration, where the code file is:

ImportCom.test String ret = Sqrtcalc.sqrt (  "4.0")  Log.info ( "value=" + ret ) //Use import of the jar package address as the code above 
//string ret = com.test.sqrt ( "4.0") //log.info ( "value=" + RET)

To see the results conveniently, open the "option –> Log Viewer" here, such as:

5. Click to run, in the log can see the corresponding results,

Here is just a relatively simple introduction of the jar package and function of the call, a bit of knowledge I also in the study .....

Using external Java files in JMeter

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.