How to get the name of the Parent Controller from

2020-07-20 04:31发布

问题:

My Jmeter Project Structure is like following, and I have a Beanshell Post Processor as a child node. How can I get the name of the Parent controller(Simple Controller 01) from the BeanShell post processor? Your help is highly appreciated.

 Thread Group
  |
  |_ Simple Controller 01
  |__ Sampler 01
  | |__ Beanshell Post Processor
  |__ Sampler 02
  |
  |_ Simple Controller 02
  |_ Sampler 03

回答1:

Directly it is not possible due to JMeter API design limitations so I'd suggest to redesigning your test plan so you would know parent controllers name.

Indirectly you can figure that out by getting access to the HashTree structure representing JMeter Test Plan using Reflection:

Remember, any time you bypass Java limitation using Reflection somewhere somehow a kitten dies, so think one more time, most probably you won't need to play this trick.

More information on using Beanshell in JMeter: How to Use BeanShell: JMeter's Favorite Built-in Component