如何在BeanShell Sampler中将Jmeter变量添加到JAVA变量?

时间:2015-07-09 13:20:41

标签: java jmeter beanshell

BeanShell采样器

int totalVerify = Integer.parseInt("${total}");
int totalBefVerify = Integer.parseInt("${totalBefVerify}");


totalVerify+${addTo};

if (totalVerify == totalBefVerify) {
return true;
}

return false;

结果

int totalVerify = Integer.parseInt("4100");
int totalBefVerify = Integer.parseInt("4104");

totalVerify+4;

if (totalVerify == totalBefVerify) {
return true;
}

return false;

预期结果为真,但由于某种原因,Java变量未添加到jmeter变量。你能帮我解决一下吗?

1 个答案:

答案 0 :(得分:1)

我发现我弄错了。见第三行。

int totalVerify = Integer.parseInt("4100");
int totalBefVerify = Integer.parseInt("4104");

**totalVerify=**totalVerify+4;

if (totalVerify == totalBefVerify) {
return true;
}

return false;