randomjmeterthreadgroup

Does JMeter support to select a sampler in Thread Group randomly?


In my Test Plan, I have Thread Group with 5 Samplers. Is there a way with JMeter that I want to select one among the 5 samplers in Thread Group Randomly and do performance testing to only that particular sampler ?


Solution

    1. Add User Defined Variables to your Test Plan and create i.e. randomSampler variable with the value of ${__Random(0,4,)} (use __Random() function to generate a random number between 0 and 4 inclusively)

      enter image description here

    2. Add Switch Controller to your Thread Group and use ${randomSampler} as the "Switch Value"

      enter image description here

    3. Put your Samplers under the Switch Controller

    4. That's it, each time you run the test the random Sampler will be chosen and executed:

      enter image description here