0
votes

I am trying to run a test in JMeter for about 15 threads/users with ramp up period of 1 seconds and Loop count of 1. My test is to take a survey which consists of answering a few questions located on various consecutive survey pages. When the survey taking starts, there is a unique id assigned to the session under the email_address variable. I am using '${__RandomString(7,abcdefghijklmnopqrstuvwxyz,)}' in User Defined Variable to assign email address dynamically. It is executing test only for one user probably the first user. Rest of them do not execute at all.

However, when I use Random Variable instead of User Defined Variables, then it works fine where the email address is given a dynamic value among the range that I specify. But for our tests, we need to use alphanumeric variables instead of just numeric variables.

Please assist.

2

2 Answers

0
votes

User Defined Variables element lets you define an initial set of variables, just as in the Test Plan.It is executed once processed at first irrespective of their physical placement within the element tree and shared among all the threads.

Hence value set is shared among all the thread.

Use of User Defined Variables element is not suitable for generating random email for each thread/user.

Place the RandomString function with required parameters directly as the value in Sampler.

0
votes

Looking into User Defined Variables documentation:

Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.

For defining variables during a test run, see User Parameters. UDVs are processed in the order they appear in the Plan, from top to bottom.

So add User Parameters as a child of the request where you need to use the random string and configure it as follows:

enter image description here

As you can see, the variable gets a new value each iteration:

enter image description here

If you want to make the string alphanumeric - just add numbers from 0 to 9 into the __RandomString() function like:

${__RandomString(7,abcdefjhijklmnopqrstuvwxyz0123456789,)}

or use the equivalent __groovy() function:

${__groovy(org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric(7),)}

More information: A Quick Guide to JMeter PreProcessors