Search code examples
jmeterbeanshell

JMeter BeanShell - integer to string


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.


Solution

  • 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