BeanShell脚本:
test("ceshi function>>>");
public void test(String str){
log.info("test...."+str);
}
错误日志:
2020-08-13 19:29:28,798 INFO o.a.j.t.JMeterThread: Thread started: 数栈-StreamApp接口 1-1
2020-08-13 19:29:28,800 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` test("ceshi function>>>"); public void test(String str){ log.info("test...."+ . . . '' : Command not found: test( java.lang.String )
2020-08-13 19:29:28,800 WARN o.a.j.p.j.s.BeanShellSampler: Exception executing script. org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: `` test("ceshi function>>>"); public void test(String str){ log.info("test...."+ . . . '' : Command not found: test( java.lang.String )
2020-08-13 19:29:28,800 INFO o.a.j.s.FileServer: Stored: ./login.csv
排查问题步骤:
- 排除语法错误
- 网上Jmeter BeanShell自定义函数的资料不多,看到仅有的资料都是先定义后调用的。将脚本中函数改成先定义后调用后,运行正常
public void test(String str){
log.info("test...."+str);
}
test("ceshi function>>>");
运行日志:
020-08-13 19:40:36,866 INFO o.a.j.t.JMeterThread: Thread started: 数栈-StreamApp接口 1-1
2020-08-13 19:40:36,867 INFO o.a.j.u.BeanShellTestElement: test....ceshi function>>>
2020-08-13 19:40:36,867 INFO o.a.j.s.FileServer: Stored: ./login.csv