JMeter BeanShell - integer to string

Paili picture Paili · Nov 24, 2015 · Viewed 19.5k times · Source

Just trying to convert an integer to a string.

vars.put("test", i);

I'd like to put the value in the variable "test", but it does not working and I think I must convert the int to a string. But I have no idea how to do that. I just found a out how to parsing string to integer in BeanShellSampler.

Answer

Dmitri T picture Dmitri T · Nov 24, 2015

Use String.valueOf() method

vars.put("test", String.valueOf(i));

Additional information on Beanshell scripting in JMeter - How to Use BeanShell: JMeter's Favorite Built-in Component