0
以下代碼在BeanShell中當我在GUI模式下使用Jmeter運行測試時,PostProcessor可以正常工作。如果我從命令行運行它,我會得到以下例外:BeanShell PostProcessor錯誤Jmeter GUI工作,命令行不行
015/09/10 18:25:13 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``notFound="NOT_FOUND"; vars.put("AUDIT_CODE",notFound . . . '' : Typed variable declaration
2015/09/10 18:25:13 WARN - jmeter.extractor.BeanShellPostProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``notFound="NOT_FOUND"; vars.put("AUDIT_CODE",notFound . . . '' : Typed variable declaration
任何想法爲什麼會發生這種情況?
String notFound="NOT_FOUND";
vars.put("AUDIT_CODE",notFound);
String auditCode=vars.get("AUDIT_CODE");
if(auditCode.equals("NOT_FOUND")){
if (vars.get("AUDITS_RESULT_0")!=null){
String audit = vars.get("AUDITS_RESULT_0");
if(audit.contains("WAITING")){
String[] auditLineWithCode = audit.split("auditCode=");
String[] auditLineJustWithCode=auditLineWithCode[1].split(",");
vars.put("AUDIT_CODE",auditLineJustWithCode[0]);
log.info("AUDIT_CODE:"+vars.get("AUDIT_CODE"));
}
}
}
謝謝。我更新了代碼,這是一個錯誤的複製粘貼。問題依然如此。 – cmpl
嘗試在腳本的開頭添加'debug();'語句,它會向STDOUT輸出大量的調試信息。另一個選擇是在'try {}'block後面加上'catch(Exception ex){log info(「ERROR」,ex);}' - 這樣你就可以在* jmeter中看到失敗的細節。日誌*文件。有關JMeter中Beanshell腳本的全面信息,請參閱[如何使用BeanShell:JMeter最喜歡的內置組件](https://blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell) –