Jmeter Beanshell 脚本的调试方法
(2017-12-14 13:50:44)分类: 软件测试技术 |
ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method:
eval Sourced file: inline evaluation of: `` import
com.***cfs.common.util.***EncryptUtil; import
java.lang.String;
/ . . . '' : Typed variable declaration : Method Invocation
rst.encrypt
WARN o.a.j.m.BeanShellPreProcessor: Problem in BeanShell script. org.apache.jorphan.util.JMeterException: Error invoking bsh method: evalSourced file: inline evaluation of: `` import
com.***cfs.common.util.***EncryptUtil; import
java.lang.String;
/ . . . '' : Typed variable declaration : Method Invocation
rst.encrypt
WARN o.a.j.m.BeanShellPreProcessor: Problem in BeanShell script. org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval
具体原因却未指出,让人不知从何下手调试
解决方案:
1、有80%问题是};if else 不对称引起的,请到专业IDE中检查所有语句是否对称
2、在相关语句中用try catch 包含 例如:
try {
JsonClientUtil jcu=new JsonClientUtil();
ObjectNode
node = JsonUtil.createObjectNode();
}
catch (Throwable ex) {
log.error("Beanshell failure: ", ex);
throw
ex;
}
}
catch (Throwable ex) {
}
相关的exception信息会更详细的显示在控制台上,可以帮助找到问题原因
3、在相关语句前后添加log.info()函数
如:
String dir= System.getProperty("user.dir");
log.info("--------------------------------dir:"+dir);
可以将变量信息显示在前台。
4、添加debug()语句在脚本开头