Skip to content

Programmatically get/set JMeter variable when extending JMeter

I am building a custom config element by extending JMeter SDK. I have achieved most of my desired functionality. Last piece is to set a computed value to a JMeter variable so that it can be used in HTTP Samplers. I looked at existing components implementation – Test Plan and User Defined Variables, but could not figure steps to set a variable value. Argument and Arguments classes are the closest I could get, but not answering the question.

In my config element, I am extending AbstractConfigGui to create GUI components and AbstractTestElement to glue UI and Data.

My code is not available on public domain, but can share snippets if required for further clarifications.


You have JMeterVariables class

Class which defines JMeter variables.

You can get them from context:

JMeterVariables vars = JMeterContextService.getContext().getVariables();