In JMeter, I have a group of threads, and I want to control how many threads are executed using the jmeter variable. In the thread group, I set the number of threads equal to ${numThreads} . I have a group of installation threads that has a bean shell sampler with the following (this is always done before the main group of test threads):
vars.put("numThreads","5");
If I installed numThreads in a user-defined variable configuration item in the installation thread group, it will use the correct number of threads. However, I want to control it using the variable I defined in the bean shell sampler, and it does not work. I see that the variable is being created, and I can print the value in the log, but when I use the bean shell sampler, the group of threads incorrectly creates 5 threads (creates 0 threads). The only thing I can think of is that they create variables, but maybe the user configuration element creates it as an integer type? When I debug a variable type, it displays as a string, regardless of whether it is set in the user configuration parms or bean shell sampler.
log.debug(vars.get("numThreads").getClass().getName()); // this prints java.lang.String for both
Why is the thread group not creating the correct number of threads based on the bean shell variable?
java jmeter
George
source share