When I script large JMeter projects I immediately default to run scripts through config files. That means that all sorts of variables get pre loaded at the start of the test (VariablesFromCSV is a huge help!). From there I control things like URLs, usernames and passwords,… but I also control Thread Groups. Recently I came across the issue that I wanted to switch in such a config file between a test that ran for a certain length of time to a test that ran only X number of iterations.
For all of you that have used JMeter you know that that might be an issue.
In the UI that looks like the image on the left. So how do you get to set the tickbox from the variable?
Well , Google was no use here. So I followed my instinct + JMeter logic and put in -1 as the value for ${NumberOfReps}. And viola, it works like a charm!
The cool thing is, that you can do the same thing with Duration. The duration thereby becomes insignificant and the script will only do ${NumberOfReps}. Just note not to set both to -1 as that would be a test that runs forever.
The only remaining issue is, how to control the Constant Throughput Timer. Sadly here the -1 doesn’t work as expected. It basically brakes the test. Theoretically you can enter a ridiculously large number and it would equate to “No” constant throughput i.e. go as fast as you can. I have tested it but not in earnest. It looks like it would do what’s expected but I can’t be 100% sure.
by Oliver Erlewein