Jmeter Beanshell错误

jas*_*een 1 jmeter beanshell

我得到了以下错误

     ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval  In file: inline evaluation of: ``import java.text.*; import java.io.*; import java.util.*; import org.apache.jmet . . . '' Encountered "/" at line 15, column 74.
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉导致问题的原因.谢谢.

Dmi*_*i T 5

您可以使用以下方法调试Beanshell脚本:

  1. debug();在脚本的开头添加行并检查STDOUT,这样您就可以看到究竟发生了什么
  2. 添加额外的日志记录,log.info("something");这样您就可以通过查看jmeter.log文件来确定哪些行正常以及执行停止的位置
  3. 将代码包装到try/catch块中,如下所示:

    try {
        //your Beanshell code here
    } catch (Exception ex) {
        log.info("Script execution failed", ex);
    }
    
    Run Code Online (Sandbox Code Playgroud)

异常详细信息将打印到jmeter.log文件,它比Error invoking bsh method一个信息更丰富.

请参阅如何使用BeanShell:JMeter最喜欢的内置组件指南,以获取更多提示和技巧.