jmeter BeanShell断言(数据类型转换)

jmeter正则表达式获取的变量的值是String类型,有时候需要进行加减操作,就需要转换类型,在这里用了BeanShell
下面是代码,以作参考,此处是将String类型转换成了double类型

String frozen_money = vars.get("VACANCY_1");
log.info("冻结金额------"+frozen_money);
String vacancy = vars.get("VACANCY_2");
log.info("总金额-----"+vacancy);
String account_vacancy = String.valueOf(Double.parseDouble(vacancy)-Double.parseDouble(frozen_money));
log.info("可用金额-----"+account_vacancy);
String frozen_money1 = vars.get("accountinfo_g1");
log.info("accountinfo_g1-----"+frozen_money1);
String account_vacancy1 = vars.get("accountinfo_g2");
log.info("accountinfo_g2-----"+account_vacancy1);
if (frozen_money.equals(frozen_money1) && account_vacancy.equals(account_vacancy1)){
	FailureMessage = "ok!";
	}
else{
	Failure = true;
	FailureMessage = "可用金额显示错误";
	}

你可能感兴趣的:(jmeter)