Am 22.08.2018 um 17:06 schrieb Felix Schumacher:
Am 21.08.2018 um 21:32 schrieb David Fertig:
I have a variable called numFiles, which I can print and verify
contains an integer.
Integer numFiles = vars.getObject("numFiles");
I want to make a random number between 0 and that value. But all of
the following fail
${__Random(0,__ ${numFiles},docIndex)};
Integer docIndex = ${__Random(0,${numFiles})};
${__Random(0,__ numFiles,docIndex)};
Integer docIndex = ${__Random(0,numFiles)};
All with an errors like:
Uncaught Exception java.lang.NumberFormatException: For input string:
"${NUMFILES}". See log file for details.
Uncaught Exception java.lang.NumberFormatException: For input string:
"numFiles". See log file for details.
How do I pass a variable into the random() function?
It seems that this is a bug. At the moment the Strings given to
__Random will not be evaluated (and therefore the Integer will not be
transformed into a String).
On second thought "bug" might be a bit harsh, as no function in JMeter
will currently transform those values by itself (yet?).
To answer your question, you could use __evalVar function to convert
your Integer into a String:
${__Random(0,${__evalVar(numFiles)})}
Regards,
Feli
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]