Calling Jmeter Functions from BeanShell Assertion Script

旧时模样 提交于 2020-01-06 02:59:11

问题


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;

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: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String str = "${__CustomFunction("FilePath")}"; int i = Integ . . . '' : Typed variable declaration : Method Invocation Integer.parseInt

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.


回答1:


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

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

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



来源:https://stackoverflow.com/questions/13166543/calling-jmeter-functions-from-beanshell-assertion-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!