in User parameters I have:
in User Defined Variables I have:
In pre processor I have:
def varB = vars.get("varB");
def varA = vars.get("varA");
log.info(varB);
log.info(varA);
in post processor I have:
def varA = vars.get("varA");
def varB = vars.get("varB");
log.info("varA = $varA");
log.info("varB = $varB");
vars.put("varB", "varA");
log.info("After change = $varB");
But varB is not updating:
2023-03-04 12:51:33,674 INFO o.a.j.m.J.JSR223 PreProcessor: xyz
2023-03-04 12:51:33,674 INFO o.a.j.m.J.JSR223 PreProcessor: abc
2023-03-04 12:51:33,913 INFO o.a.j.e.J.JSR223 PostProcessor: varA = abc
2023-03-04 12:51:33,914 INFO o.a.j.e.J.JSR223 PostProcessor: varB = xyz
2023-03-04 12:51:33,914 INFO o.a.j.e.J.JSR223 PostProcessor: After change = xyz
I am trying to store the value of varA
so that I can use it in another test payload (same thread group, and I do not want to use properties)
No it's accessible in your case. the mistake is in saving the parameter. instead of passing the variable, you passed that as string
def varA = vars.get("varA");
def varB = vars.get("varB");
log.info("varA = $varA");
log.info("varB = $varB");
vars.put("varB", varA);
log.info("After change = "+ vars.get("varB"));
This gives the below expected output
*
2023-03-04 23:33:43,691 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2023-03-04 23:33:43,707 INFO o.a.j.m.J.JSR223 PreProcessor: xyz
2023-03-04 23:33:43,707 INFO o.a.j.m.J.JSR223 PreProcessor: abc
2023-03-04 23:33:43,753 INFO o.a.j.e.J.JSR223 PostProcessor: varA = abc
2023-03-04 23:33:43,753 INFO o.a.j.e.J.JSR223 PostProcessor: varB = xyz
2023-03-04 23:33:43,753 INFO o.a.j.e.J.JSR223 PostProcessor: After change = abc