JMeter: How may I sum random 2 float numbers

时光总嘲笑我的痴心妄想 提交于 2019-12-13 08:58:54

问题


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


回答1:


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:

More information: Mathematical Functions and Converting Data Types in Groovy



来源:https://stackoverflow.com/questions/52500217/jmeter-how-may-i-sum-random-2-float-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!