JMeter: How may I sum random 2 float numbers

2019-09-20 05:54发布

How do I allow jmeter to generate 2 seperate decimal values and use it in 2 parameters in http requests?

1条回答
仙女界的扛把子
2楼-- · 2019-09-20 06:45

You can generate a random float value using either any of JSR223 Test Elements and Groovy language or __groovy() function, the relevant code would be something like:

org.apache.commons.lang3.RandomUtils.nextFloat(0.0f, 100f)

in case of _groovy() function you need to escape the comma like:

${__groovy(org.apache.commons.lang3.RandomUtils.nextFloat(0.0f\, 100f),)}

it will return a random float number in range from 0 to 100 (adjust as needed)

Demo:

JMeter Groovy Sum Random Floats

More information: Mathematical Functions and Converting Data Types in Groovy

查看更多
登录 后发表回答