Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JMeter Function to retrieve specific value 90% of times from give values

I have a list of values ["Sport","movies"]

I need to pass value "Sport" 90 percent of times and "movies" 10% of times to variable name result.

Is there any way/JMeter function, to get specific value X percent of times.
We have Random function but it returns random value.
Can any one help on this.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The easiest way is creating a CSV file with 9 lines of Sport and one line of movies and then read this file in the CSV Data Set Config.

Alternatively you can use a suitable JSR223 Test Element or __groovy() function with the following code:

def list = (1..9).collect { 'Sport' }
list.add('movies')

vars.put('result', list.get(org.apache.commons.lang3.RandomUtils.nextInt(1, 10)))

More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading