【报错】
2022-04-28 14:00:58,491 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String questions_one = vars.get("questions_one"); String expected_first_response . . . '' : Typed variable declaration
2022-04-28 14:00:58,491 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String questions_one = vars.get("questions_one"); String expected_first_response . . . '' : Typed variable declaration
【脚本】
String questions_one = vars.get("questions_one");
String expected_first_response = vars.get("expected_first_response");
String is_first_sort = vars.get("is_first_sort");
if (questions_one.equals(expected_first_response)){
String is_first_sort = "1";
}else{
String is_first_sort = "0";
}
vars.put("is_first_sort",is_first_sort);
int num = vars.get("response_question_matchNr");
log.info("推荐问题数量为:{}", vars.get("response_question_matchNr"));
int num = String.valueof("${response_question_matchNr}"); //获取推荐问题列表的元素个数
int num = (int)vars.get("all_count");
log.info("all_count:{}", num);
for(i=1;i<=num;i++){
String question = vars.get("response_question_"+i); //response_question_? 获取列表元素
log.info("推荐问题:{}", question);
questionStrList += question+",";
}
questionStrList = questionStrList.substring(0,question.length()-1);//从 start 处到 stop-1 处的所有字符
questionList = "[" +questionStrList +"]";
log.info("推荐问题列表为:{}",questionList);
vars.put("questionList",questionList); //保存为jmeter变量参数
samjquan
(霍格沃兹-阿宏)
2
代码自己写的吗?从第一行开始,一行一行注释调试。
- 获取不到变量的值,会报错。
- 语法使用错误也会报错。
int num=Integer.valueOf(vars.get("all_count"));
log.info("all_count:{}", num);