Class DslVariables
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
-
- us.abstracta.jmeter.javadsl.core.configs.BaseConfigElement
-
- us.abstracta.jmeter.javadsl.core.configs.DslVariables
-
- All Implemented Interfaces:
DslConfig,DslTestElement,DslTestPlan.TestPlanChild,BaseSampler.SamplerChild,MultiLevelTestElement,BaseThreadGroup.ThreadGroupChild
public class DslVariables extends BaseConfigElement
Allows setting JMeter thread variables that can be used later on in JMeter expressions or JSR223 scripts.When you only need to reuse some string or value, prefer using java variables instead of creating jmeter variables, which is easier to maintain, and makes the test plan more efficient (fewer variables in memory).
This internally uses JMeter User Defined Variables element when variables are included at test plan level, but uses JSR223 sampler otherwise to provide more consistency and avoid confusion generated by User Defined Variables semantics (like non reinitialization in threads iterations, vars cross-references, vars scope, etc. Check red blocks comments in JMeter component documentation).
- Since:
- 0.50
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDslVariables.CallContextEntrystatic classDslVariables.CodeBuilder
-
Constructor Summary
Constructors Constructor Description DslVariables()DslVariables(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.jmeter.testelement.TestElementbuildTestElement()org.apache.jorphan.collections.HashTreebuildTreeUnder(org.apache.jorphan.collections.HashTree parent, BuildTreeContext context)Builds the JMeter HashTree for this TestElement under the provided tree node.DslVariablesset(String varName, String varValue)Allows setting a JMeter thread variable.-
Methods inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
buildConfiguredTestElement, buildTestElementGui, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGui
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface us.abstracta.jmeter.javadsl.core.DslTestElement
showInGui
-
-
-
-
Constructor Detail
-
DslVariables
public DslVariables()
-
DslVariables
public DslVariables(String name)
-
-
Method Detail
-
set
public DslVariables set(String varName, String varValue)
Allows setting a JMeter thread variable.When the variable is set at test plan level, one variable for each thread group is created at test plan start with given name and value. When inside a thread group, controller, etc, it will only be created/updated with given value when such point in test plan is reached.
- Parameters:
varName- specifies the name of the variable to register. This can be a literal value (eg: "test") or a JMeter expression (eg:${VAR_NAME}).varValue- specifies the value associated to the variable. This can be a literal value (eg: "test") or a JMeter expression (eg:${VAR_VALUE}).- Returns:
- the DslVariables instance for further configuration or usage in test plan.
-
buildTreeUnder
public org.apache.jorphan.collections.HashTree buildTreeUnder(org.apache.jorphan.collections.HashTree parent, BuildTreeContext context)Description copied from interface:DslTestElementBuilds the JMeter HashTree for this TestElement under the provided tree node.- Specified by:
buildTreeUnderin interfaceDslTestElement- Overrides:
buildTreeUnderin classBaseTestElement- Parameters:
parent- the node which will be the parent for the created tree.context- context information which contains information shared by elements while building the test plan tree (eg: adding additional items to test plan when a particular protocol element is added).- Returns:
- The tree created under the parent node.
-
buildTestElement
protected org.apache.jmeter.testelement.TestElement buildTestElement()
- Specified by:
buildTestElementin classBaseTestElement
-
-