3

In JMeter, I have a test plan with a thread group. The thread group has number of threads and a loop count which can be set in the gui.

Is there anyway I can figure out dynamically what they have being set so I can pass them to variable?

Thanks.

dublintech
  • 16,815
  • 29
  • 84
  • 115

3 Answers3

3

Use BeanShell PostProcessor with following code:

vars.put("threads", Integer.toString(prev.getAllThreads()));

Or maybe you just looking for this: http://code.google.com/p/jmeter-plugins/wiki/ActiveThreadsOverTime

Andrey Pokhilko
  • 2,578
  • 18
  • 19
  • I am just looking for the value of Number of Threads (users): on the thread group panel. Reason is, I have a batch of jmeter scripts I want to kick off and I want the results saved to different files names and for the number of users to be in the actual filename. Something like, mythreadgroup_3_users.csv. Many thanks – dublintech May 11 '12 at 16:04
  • Ok, I got it. Next answer for you. – Andrey Pokhilko May 11 '12 at 18:49
2

You can parametrize the thread count defining a property like

${__P(users, 1)}

and if you run the test plan from command line, you can specify its value as -Jusers=XX. If, instead, you run the test from JMeter gui, to verify the text plan for example, the users property assume the default value of 1.
Don't forget to reference the property in the thread count, with ${users}.

Carlo
  • 1,686
  • 3
  • 29
  • 43
  • Just to be clear, `users` here is a JMeter property, not a variable. There are many differences between the two constructs and having the right name will make reading the docs much easier :) – Shawn Apr 19 '17 at 15:30
  • Ok, thanks for the correction, I've edited the answer accordingly. – Carlo Apr 20 '17 at 06:44
1

You should parameterize your thread count at TestPlan level settings, then use that parameter (variable) both in ThreadGroup and Listener.

If the value varies and you want to pass it from command line use __P() function instead of variable.

Andrey Pokhilko
  • 2,578
  • 18
  • 19