Reputation: 143
Essentially, I'd like to have a counter in my load test that is user specific (each user gets their own counter that is initialized at 1) but is incremented each time it is invoked throughout test execution.
In other words, I'd like the following behavior out of my counter:
Request 1:
<item position="${POSITION_CTR}"... > //Counter is 1
<item position="${POSITION_CTR}"... > //Counter is 2 despite same request
Request 2:
<item position="${POSITION_CTR}"... > //Counter is 3
Request 3:
<item position="${POSITION_CTR}"... > //Counter is 4
I have attempted to use the __counter(TRUE, POSITION_CTR) function. Unfortunately, this results in a value of "1" no matter how many times I call it. I considered using a BeanShell Post processor to programmatically increment the counter value after each request, but then a request that uses the counter twice (which should be unique) will have identical counter values.
I also attempted to use a Counter (Config Element) but seemed to have the same issue as with __counter(). Any suggestions would be much appreciated.
Upvotes: 1
Views: 4243
Reputation: 113
You can try with __setProperty() in "BeanShell PostProcessor" to increment the values. But be careful, it will reflect to all the threads in Test plan.
For example, use below in BeanShell PostProcessor:
__setProperty("counter", "${__javaScript(${__property(counter)} + 1}
You can also try using var.put as below:
vars.put("counter", "${__javaScript(${counter} + 1}
Upvotes: 1