Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jmeter : Increment count of user variable for n user(thread) and n request

I have Jmeter test with following scenario:

Thread (5 in number)
  -> counter X (X value 0, increment by 1 till 10)
  -> req1 uses X
  -> req2 uses X

Now what I want to achieve is that, for each user and each request the value of X should increment without overlapping/repeating i.e If I run it for 5 user * 2 runs = 10 request, than value of X for each request should very from 1 to 10 without repetition.

But above approach does not work as the each user the counter start from 0 so I get duplicate X in request made, something like

user1 -> req1 X = 0, 
user1 -> req2 X = 1
user2 -> req1 X = 0
user2 -> req2 X = 1

I tried to use user defined variable with : bean shell pre-process still the same issue. even the ${__intSum(${X},1,X)} does not solve the issue. even tried ${__counter(TRUE,X)} does not solve the issue.

like image 971
sanjaykumar81 Avatar asked Feb 11 '23 13:02

sanjaykumar81


1 Answers

JMeter Counter by default does not give duplicate value - gets incremented automatically for each user & for each iteration.

Uncheck 'Track counter independently for each user' check box.

enter image description here

EDIT:

If your requirement is to increase the counter for each request inside a thread-group, It is not possible with counter. You can use JMeter properties to do that.

Check here - http://jmeter.apache.org/usermanual/best-practices.html - Sharing Variables.

like image 179
vins Avatar answered Apr 27 '23 02:04

vins