In Jmeter assertion main trying to compare values of 2 variables with double data type. following script I'm using to cast a value in double
double actual = vars.getObject("Merticvalue");
log.info ("Actual MetricValue is found to be " + actual);
double expected=153.60
vars.putObject("expected",expected);
if (vars.getObject("expected") != vars.getObject("actual")) {
props.put("testcaseExecutionStatus",5);
String Status = props.get("testcaseExecutionStatus").toString();
log.info("Status:"+ Status)
return;
}
props.put("testcaseExecutionStatus",1);
String Status = props.get("testcaseExecutionStatus").toString();
log.info("Status:"+ Status)
I'm getting this error:
GroovyCastException: Cannot cast object '153.60'
with class 'java.lang.String' to class 'double'
The issue is getting Merticvalue
value with is saved as String, you can cast it:
double actual = Double.valueOf(vars.getObject("Merticvalue"));