Alexa, tell VoxSnap to play posts from BlazeMeter
When it comes to building various types of advanced JMeter test plans, which include not only replaying a recorded test scenario with an increased number of users, but something more complex, you will likely need some form of a Counter.
These scenarios can include test plans that:
● are dependent on external data sources like a CSV Data Set, JDBC Result Set or previous response
● the target is just to run a test (or a part of a test) several times and each time have a dynamic parameter that represents a current iteration number
This post will detail how to use a counter and a loop controller in JMeter in order to efficiently run these complex tests.
Using the Counter Config Element
Let’s imagine a scenario in which you need to create five entities in a loop using the HTTP Request sampler and each entity name has to be unique.
The bad way to go about this is to copy and paste the relevant request five times.
It works and it works fine, but what if you need to do it 100 times? 200 times? What if you need to add one more parameter to the HTTP Request? Code duplication isn’t a very good idea by itself - it’s better to design reusable components in the form of pluggable modules, use loops and other logic controllers in order to keep your test as short as possible.
The better way is to use a Loop Controller and a Counter.
Now let’s implement the same scenario using a single HTTP Request run via parameterized iterations. To do so:
● Add a Loop Controller and set the “Loop Count” to 5
● Define a Counter inside the Loop Controller and configure it as follows:
● “Start” - this is initial counter value, let’s make it 1 (If you leave it blank, the Counter will start from zero.)
● “Increment” - this value will be added to the current Counter value once the Counter is hit. Let’s make it 1 as well as we need to replicate the above behavior
● “Maximum” - this is pretty much self-explanatory. If it is left blank, the Counter value will increment infinitely. When it is set and the current counter value exceeds the “maximum” value, counter starts over. So it is fine either to leave it blank or to set it to 5 or above
● “Number Format” - you can change the output number format using this parameter. If it is left blank, the values will be “normal” like 1, 2, 3, etc. If you put “00” into the field, the values will be prefixed by double zeros like 001, 002, 003, etc. For this exercise let’s leave …