简体   繁体   中英

How to add a Jmeter variable to JAVA variable in BeanShell Sampler?

BeanShell Sampler

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


totalVerify+${addTo};

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

return false;

Result

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

totalVerify+4;

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

return false;

Expected result is true, but for some reason Java variable is not adding to jmeter variable. Could you please help me to resolve this.

I found that I made a mistake. See third line.

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

**totalVerify=**totalVerify+4;

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

return false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM