The Counter element is a built-in feature of JMeter which generates sequential reference numbers within the scope of a thread group. These sequential numbers can be useful in identifying or grouping requests originating from a discrete iteration within a recurring process. In this brief article, we will review the features of the Counter element and describe how it may be utilized in a JMeter load test.
Configuring the Counter Element
There are several parameters that may be set for the Counter element to control its behavior:
- Starting value – the initial value the counter will start with.
- Increment – the number by which the counter value will increase with each iteration.
- Maximum value – the maximum value the counter will assume.
- Number format – formatting applied to counter value.
- Exported variable name – name of the variable containing counter value.
There are also check boxes that control how counter values are used and regenerated. If the “track counter independently for each user” option is set, the counter tracks separate values for each virtual user.
Using the Counter in JMeter Tests
Based on the name ascribed in the configuration above, the Counter element will populate a user variable with the current counter value. This can be accessed in your tests using ${...}
convention or property notation. Query strings, request arguments, and custom scripting variables can be set to this value and thereby associated with a discrete sequenced value.
Did you know that RedLine13 offers a full-featured, time-limited free trial? Sign up now, and start testing today!