从BeanShell断言脚本调用Jmeter函数 [英] Calling Jmeter Functions from BeanShell Assertion Script

查看:957
本文介绍了从BeanShell断言脚本调用Jmeter函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Eclipse中运行jmeter测试套件.
在我的测试套件中,我正在使用BeanShellAssertion来计算csv文件中的行数.
我有一个自定义的jmeter函数.
BeanShellAssertion的脚本是:

I am trying to run the jmeter test-suites in eclipse.
In my test-suite I am using a BeanShellAssertion to count the number of rows in a csv file.
I have a custom jmeter function to do so.
The script of the BeanShellAssertion is :

String str = "${__CustomFunction("Path to the CSV file")}";
int i = Integer.parseInt(str);
if(i ==0)
{
   Failure = true;
   FailureMessage = "Failed!";
}
return i;

当我在本地计算机上使用jmeter运行该测试套件时,它可以正常工作.
仅当我尝试使用eclipse运行它时(使用jmeter maven插件),我才看到以下错误:

This test-suite works fine when I run it using the jmeter on my local machine.
Only when I try to run it with eclipse, (using the jmeter maven plugin) I see the following error:

jmeter.util.BeanShellInterpreter:调用bsh方法时出错: eval源文件:对以下内容的内联评估:``String str = "$ {__ CustomFunction(" FilePath)}"; int i =整数. . . '':打字 变量声明:方法调用Integer.parseInt

jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String str = "${__CustomFunction("FilePath")}"; int i = Integ . . . '' : Typed variable declaration : Method Invocation Integer.parseInt

我想知道使用eclipse执行jmeter函数时是否还有其他方法可以调用jmeter函数,原因是我确定该函数是正确的,正如我之前提到的那样,当在本地使用jmeter运行测试套件时,该函数可以正常工作机器.

I am wondering if there's some other way to invoke the jmeter functions when executing it using eclipse cause I am sure that the function is correct as I mentioned before that it works fine when the test suite is run using the jmeter on my local machine.

任何帮助将不胜感激. 谢谢.

Any help would be appreciated. Thanks.

推荐答案

您确定自定义函数jar对Maven插件可见吗?

Are you sure your custom function jar is visible for the Maven Plugin ?

当您从JMeter运行它时,它可以正常工作,我想您在lib/ext中有一个jar.

As when you run it from JMeter, it works , I suppose you have a jar in lib/ext.

因此,您需要使该jar可供jmeter maven插件使用.

So you need to make this jar available to the jmeter maven plugin.

这篇关于从BeanShell断言脚本调用Jmeter函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆