0
votes

I have a test that loops as suggested here: Is it possible to loop a test in JMeter?

I have a Thread Group with 100 users and a loop count of 5. A Runtime Controller to run for 30 seconds.

Now when the Runtime Controller finishes I would like to increment a variable that I can read inside my BeanShell sampler in my test. At the end of the test this variable should be equal to the loop count.

2

2 Answers

1
votes

Ok figured it out!

I used a Counter element and set it to "Track counter independently for each user".

The variable increments only after each loop.

Also very important the Counter has to be under Thread Group but not inside the Runtime Controller.

1
votes

Since you use Beanshell you can access current loop number as simple as

vars.getIteration();

See JMeterVariables class JavaDoc to see what else could be done using it, How to use BeanShell: JMeter's favorite built-in component guide for advanced information on Beanshell scripting in Apache JMeter and remember that the method will work only on Thread Group level, the value won't increment inside Loop Controller