Get number of threads (defined via BlazeMeter) in a thread group from the setup thread group (jmeter)

爱⌒轻易说出口 提交于 2019-12-25 16:09:09

问题


I have a JMeter test plan which performs a simple action once. When I upload the test to BlazeMeter, I can then choose the number of threads I want for my thread group and run the test.

The problem I am having is that my test setup needs to know how many threads the thread group will have. To make things clearer, here is a simple representation of the test plan:

setUp Thread Group
  needs to know the number of threads in the below thread group
Thread Group
  The number of threads for this thread group is determined via BlazeMeter test configuration

Within the non-setup thread group, I can dynamically get the number of threads assigned via BlazeMeter, but I can't find any way of getting this number from within the setup thread group.

Any ideas?


回答1:


You can do it using the following Groovy code:

def numberOfThreads = ctx.getThreadGroup().getNumThreads()

Demo:

The approach is environment-agnostic so you can use it anywhere. It may be more handy to use __groovy() function like: ${__groovy(ctx.getThreadGroup().getNumThreads(),)}

See Groovy Is the New Black article for more information on using Groovy scripting in JMeter tests.



来源:https://stackoverflow.com/questions/43500371/get-number-of-threads-defined-via-blazemeter-in-a-thread-group-from-the-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!