JMeter,BeanShell断言比较多次迭代

时间:2017-12-08 01:13:33

标签: javascript jmeter beanshell

我有问题。在我的测试用例中,每次迭代都有一个响应不同或不同的数字变量,取决于数据输入。例。第一次迭代响应一个代码和一个描述;第二次迭代响应两个代码和两个描述;和类似的。我需要插入一个BeanShell Assertion来验证每次迭代的响应。 第一步:添加一个TWO正则表达式提取器(每个变量一个) Regular Expression for "clave"

Regular Expresion for "Descripcion"

我在BeanShell断言中的代码不起作用;仅提取每个RegEx Extractor的第一个值

String Resp_clave_g1 = vars.get("Resp_clave_g1"); //Obtained from Regular Expresion Extractor
String Resp_descripcion_g1 = vars.get("Resp_descripcion_g1"); //Obtained from Regular Expresion Extractor
String Resp_clave_g2 = vars.get("Resp_clave_g2"); //Obtained from Regular Expresion Extractor
String Resp_descripcion_g2 = vars.get("Resp_descripcion_g2"); //Obtained from Regular Expresion Extractor
String Resp_clave_g3 = vars.get("Resp_clave_g3"); //Obtained from Regular Expresion Extractor
String Resp_descripcion_g3 = vars.get("Resp_descripcion_g3"); //Obtained from Regular Expresion Extractor
String Resp_clave_g4 = vars.get("Resp_clave_g4"); //Obtained from Regular Expresion Extractor
String Resp_descripcion_g4 = vars.get("Resp_descripcion_g4"); //Obtained from Regular Expresion Extractor
String Resp_clave_g5 = vars.get("Resp_clave_g5"); //Obtained from Regular Expresion Extractor
String Resp_descripcion_g5 = vars.get("Resp_descripcion_g5"); //Obtained from Regular Expresion Extractor
String Resp_clave_g6 = vars.get("Resp_clave_g6"); //Obtained from Regular Expresion Extractor
String Resp_descripcion_g6 = vars.get("Resp_descripcion_g6"); //Obtained from Regular Expresion Extractor

log.warn (Resp_clave_g1);
log.warn (Resp_descripcion_g1);
log.warn (Resp_clave_g2);
log.warn (Resp_descripcion_g2);
log.warn (Resp_clave_g3);
log.warn (Resp_descripcion_g3);
log.warn (Resp_clave_g4);
log.warn (Resp_descripcion_g4);
log.warn (Resp_clave_g5);
log.warn (Resp_descripcion_g5);
log.warn (Resp_clave_g6);
log.warn (Resp_descripcion_g6);

if (Resp_clave_g1 != null && Resp_clave_g1.equals("${clave_1}") == false){ //Obtained from DataSet CSV
 	Failure = true;
	FailureMessage = "Not a valid string, expected: ${clave_1}, actual value: " + Resp_clave_g1;
}else{
	Failure = false;
}

1 个答案:

答案 0 :(得分:0)

您错过了将Match No.更改为负数为-1以返回all occurrences

  

如果匹配号设置为负数,则处理采样器数据中的所有可能匹配。