Search code examples
jmeterjmeter-5.0taurus

Incremental variable in each iteration/loop in Jmeter Tests


I have below setup for my test plan:

enter image description here

In POST http request, I am sending a variable myCount set to value 0.

As per above configuration, this test will run 100 times but everytime the value of myCount is sending 0.

I want it in incremental for example: for loop 1 value set to 1, for loop 2 value should set 2.

Please let me know how can I achieve this.

Also, I would like to know in Taurus as well.


Solution

    1. Thread Group has a pre-defined variable which returns the current iteration number, it's ${__jm__Thread Group__idx}

      enter image description here

      if you want the counting to start from 1 - go for __intSum() function

      enter image description here

    2. There is __counter() function which generates an incremented number each time it's being called

      enter image description here

    3. There is Counter configuration element which does the same but you have additional possibility to control the number format, i.e. if you need 0001 instead of just 1 or you plan to re-use the generated variable value later on within the bounds of same request or iteration. More information: How to Use a Counter in a JMeter Test

    4. With regards to Taurus - in case of JMeter executor it supports all the approaches mentioned above