I've encountered a problem when trying to update a Jmeter variable with a beanshell script. I've followed this manual and i have seen this topic and both say the same:
- To update a variable use
vars.put("variable", "newValue");
- The value that you put can only be a String.
Now I want to use this code:
String x = vars.get("counter");
int y = Integer.parseInt(x);
y = y + 1;
String z = "" + y;
vars.put("counter", z);
// print(z);
My variable counter is a user parameter (tried before as user defined variable) with the value 1. I can see my script is working because the print(z) returns the value 2. Now I also expact that my variable counter is updated in the user parameters so that when I run this again it gives me the value 3. This is not the case: The value is not updated, so everythime I run the script it returns me the value 2.
Anyone who can help me with this?